Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-12059] Swift compiler crash in SIL EarlyRedundantLoadElimination - release only #54495

Closed
swift-ci opened this issue Jan 21, 2020 · 6 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software optimized only Flag: An issue whose reproduction requires optimized compilation

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-12059
Radar rdar://problem/58997062
Original Reporter ryanw (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

FC31 with swift built from master (203a2b6) and some minimal Python 3 patches to the build system.

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, OptimizedOnly
Assignee @atrick
Priority Medium

md5: 09f6059fbe2b863d87e102961f09fbc9

Issue Description:

Compiling [this project](https://github.com/tokyovigilante/Imprint) (github.com) on with the swift 5.2-dev master branch crashes only during release builds with the following backtrace:

swift: /home/ryan/Projects/Develop/swift-source/swift/lib/SILOptimizer/Analysis/EscapeAnalysis.cpp:1575: void swift::EscapeAnalysis::ConnectionGraph::verify(bool) const: Assertion `EA->isPointer(Nd->mappedValue)' failed.
 Stack dump:
 0. Program arguments: /home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift -frontend -c /home/ryan/Projects/Develop/Imprint/Sources/EPUBCore/Errors.swift /home/ryan/Projects/Develop/Imprint/Sources/EPUBCore/FRBook.swift /home/ryan/Projects/Develop/Imprint/Sources/EPUBCore/FREpubParser.swift /home/ryan/Projects/Develop/Imprint/Sources/EPUBCore/FRMetadata.swift /home/ryan/Projects/Develop/Imprint/Sources/EPUBCore/FRResource.swift /home/ryan/Projects/Develop/Imprint/Sources/EPUBCore/FRResources.swift /home/ryan/Projects/Develop/Imprint/Sources/EPUBCore/FRSmilElement.swift /home/ryan/Projects/Develop/Imprint/Sources/EPUBCore/FRSmils.swift /home/ryan/Projects/Develop/Imprint/Sources/EPUBCore/FRSpine.swift /home/ryan/Projects/Develop/Imprint/Sources/EPUBCore/FRTocReference.swift /home/ryan/Projects/Develop/Imprint/Sources/EPUBCore/MediaType.swift /home/ryan/Projects/Develop/Imprint/Sources/EPUBCore/String+TimeParsing.swift -supplementary-output-file-map /tmp/supplementaryOutputs-9a7ca6 -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /home/ryan/Projects/Develop/Imprint/.build/checkouts/ZipReader/Sources/CShims/include -I /usr/include/minizip -g -module-cache-path /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/ModuleCache -swift-version 5 -O -D SWIFT_PACKAGE -color-diagnostics -Xcc -fmodule-map-file=/home/ryan/Projects/Develop/Imprint/.build/checkouts/Harness/Sources/CGLib/module.modulemap -Xcc -fmodule-map-file=/home/ryan/Projects/Develop/Imprint/.build/checkouts/Harness/Sources/CInotify/module.modulemap -Xcc -fmodule-map-file=/home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/CShims.build/module.modulemap -Xcc -fmodule-map-file=/home/ryan/Projects/Develop/Imprint/.build/checkouts/ZipReader/Sources/CMinizip/module.modulemap -parse-as-library -module-name EPUBCore -num-threads 20 -o /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/EPUBCore.build/Errors.swift.o -o /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/EPUBCore.build/FRBook.swift.o -o /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/EPUBCore.build/FREpubParser.swift.o -o /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/EPUBCore.build/FRMetadata.swift.o -o /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/EPUBCore.build/FRResource.swift.o -o /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/EPUBCore.build/FRResources.swift.o -o /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/EPUBCore.build/FRSmilElement.swift.o -o /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/EPUBCore.build/FRSmils.swift.o -o /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/EPUBCore.build/FRSpine.swift.o -o /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/EPUBCore.build/FRTocReference.swift.o -o /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/EPUBCore.build/MediaType.swift.o -o /home/ryan/Projects/Develop/Imprint/.build/x86_64-unknown-linux-gnu/release/EPUBCore.build/String+TimeParsing.swift.o
 1. Swift version 5.2-dev
 2. While running pass #​29355 SILFunctionTransform "EarlyRedundantLoadElimination" on SILFunction "@$s8EPUBCore12FREpubParserC19findTableOfContents33_84205204E202E37C79839ACEEE86396FLLSayAA14FRTocReferenceCGyF".
 for 'findTableOfContents()' (at /home/ryan/Projects/Develop/Imprint/Sources/EPUBCore/FREpubParser.swift:262:13)
 #​0 0x000000000462e7cf llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x462e7cf)
 #​1 0x000000000462c9e0 llvm::sys::RunSignalHandlers() (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x462c9e0)
 #​2 0x000000000462ebdf SignalHandler(int) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x462ebdf)
 #​3 0x00007f58f8c95b20 __restore_rt (/lib64/libpthread.so.0+0x14b20)
 #​4 0x00007f58f6d07625 raise (/lib64/libc.so.6+0x3c625)
 #​5 0x00007f58f6cf08d9 abort (/lib64/libc.so.6+0x258d9)
 #​6 0x00007f58f6cf07a9 _nl_load_domain.cold (/lib64/libc.so.6+0x257a9)
 #​7 0x00007f58f6cffa66 (/lib64/libc.so.6+0x34a66)
 #​8 0x0000000000bb33b0 swift::EscapeAnalysis::ConnectionGraph::verify(bool) const (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0xbb33b0)
 #​9 0x0000000000bbb585 swift::EscapeAnalysis::recompute(swift::EscapeAnalysis::FunctionInfo*) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0xbbb585)
 #​10 0x0000000000bbc2db swift::EscapeAnalysis::canEscapeTo(swift::SILValue, swift::FullApplySite) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0xbbc2db)
 #&#8203;11 0x0000000000bd5790 swift::SILInstructionVisitor<(anonymous namespace)::MemoryBehaviorVisitor, swift::SILInstruction::MemoryBehavior>::visit(swift::SILInstruction*) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0xbd5790)
 #&#8203;12 0x0000000000bd3920 swift::AliasAnalysis::computeMemoryBehaviorInner(swift::SILInstruction*, swift::SILValue, swift::RetainObserveKind) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0xbd3920)
 #&#8203;13 0x0000000000bd33a1 swift::AliasAnalysis::computeMemoryBehavior(swift::SILInstruction*, swift::SILValue, swift::RetainObserveKind) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0xbd33a1)
 #&#8203;14 0x0000000000a32def (anonymous namespace)::BlockState::processUnknownWriteInst((anonymous namespace)::RLEContext&, swift::SILInstruction*, RLEKind) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0xa32def)
 #&#8203;15 0x0000000000a28f93 (anonymous namespace)::RedundantLoadElimination::run() (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0xa28f93)
 #&#8203;16 0x000000000096194e swift::SILPassManager::runPassOnFunction(unsigned int, swift::SILFunction*) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x96194e)
 #&#8203;17 0x0000000000962666 swift::SILPassManager::runFunctionPasses(unsigned int, unsigned int) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x962666)
 #&#8203;18 0x000000000096396f swift::SILPassManager::execute() (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x96396f)
 #&#8203;19 0x00000000005826f8 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x5826f8)
 #&#8203;20 0x000000000096b7c7 swift::runSILOptimizationPasses(swift::SILModule&) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x96b7c7)
 #&#8203;21 0x00000000007949cc swift::CompilerInstance::performSILProcessing(swift::SILModule*, swift::UnifiedStatsReporter*) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x7949cc)
 #&#8203;22 0x0000000000506c2a performCompileStepsPostSILGen(swift::CompilerInstance&, swift::CompilerInvocation const&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, bool, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, bool, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x506c2a)
 #&#8203;23 0x00000000004fb573 performCompile(swift::CompilerInstance&, swift::CompilerInvocation const&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x4fb573)
 #&#8203;24 0x00000000004f86c6 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x4f86c6)
 #&#8203;25 0x0000000000489816 main (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x489816)
 #&#8203;26 0x00007f58f6cf21a3 __libc_start_main (/lib64/libc.so.6+0x271a3)
 #&#8203;27 0x000000000048945e _start (/home/ryan/Projects/Develop/swift-toolchain/usr/bin/swift+0x48945e)
@beccadax
Copy link
Contributor

@swift-ci create

@atrick
Copy link
Member

atrick commented Jan 31, 2020

To verify that this is fixed, I spend the day attempting to build swift on linux with no luck. I'm currently blocked on missing libatomic.so.

I suspect it was already fixed here, so if someone else could verify that would be nice:

commit 1654dd5
Author: Andrew Trick <atrick@apple.com>
Date: Sun Jan 19 22:41:56 2020

Cleanup EscapeAnalysis getNode and fix undef handling.

Consistently handle base and derived pointers.

Consistently avoid creating nodes for undef, which breaks
verification.

Be more precise about creating the node based on the derived pointer
type.

Remove a few extraneous helpers.

Fixes <rdar://58445744> swiftc assert during EscapeAnalysis
verification: (EA->isPointer(Nd->mappedValue)), function verify

@atrick
Copy link
Member

atrick commented Jan 31, 2020

I figured out the libatomic issue on Linux. But I now run into the same problem building Imprint:

/Users/docker_user/src/build/Imprint/.build/checkouts/ZipReader/Sources/CShims/shims.c:7:10: fatal error: 'minizip/mz.h' file not found
#include <minizip/mz.h>
^~~~~~~~~~~~~~
1 error generated.
: fatal error: 'wayland-util.h' file not found
#include "wayland-util.h"

I had assumed this project had a Linux dependence, but it doesn't look like it. Maybe something's missing from the package description and there's an assumption that minizip is already installed?

At any rate, I see now that I never cherry-picked the above commit to 5.2, so that's something I can look into.

@atrick
Copy link
Member

atrick commented Jan 31, 2020

This fix should not need to be cherry-picked to 5.2 because the verification that triggers didn't exist. I think the comment above that says "swift 5.2-dev master branch" should just say "swift master branch"

@swift-ci
Copy link
Collaborator Author

Comment by Ryan (JIRA)

Hi @atrick, thanks for looking into this. Sorry the code does currently depend on both the minizip library (for EPUB decompression) and the Wayland linux client library (for the currently largely non-existent UI). I don't know how Package.swift could deal with this currently, The CMinizip wrapper modulemap should be in the source tree though.

I'll build an updated toolchain later today (I'm on Fedora 31) and check to see if this resolves it.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Feb 1, 2020

Comment by Ryan (JIRA)

On a toolchain built from swift master @ Jan 31 the compiler no longer crashes and my project builds with a release configuration, so looks like your changes have fixed this. Thanks!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software optimized only Flag: An issue whose reproduction requires optimized compilation
Projects
None yet
Development

No branches or pull requests

4 participants