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-11030] Compiler crash when using -O flag 'While emitting IR SIL function' #53420

Closed
swift-ci opened this issue Jun 27, 2019 · 3 comments
Closed
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 IRGen LLVM IR generation optimized only Flag: An issue whose reproduction requires optimized compilation

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11030
Radar rdar://problem/52266834
Original Reporter Mikica (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

macOS 10.14.3

Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
Target: x86_64-apple-darwin18.2.0

Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
Target: x86_64-apple-darwin18.2.0

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

md5: bd85d64b9e83af473a1390c1661cea24

Issue Description:

Running swiftc -O, crashes the compiler with the following stack trace:

0  swift                    0x000000010d95959a PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010d958d4e SignalHandler(int) + 302
2  libsystem_platform.dylib 0x00007fff64fb5b3d _sigtramp + 29
3  libsystem_platform.dylib 0x00007ffee609f76c _sigtramp + 2165218380
4  swift                    0x0000000109d6ccf2 swift::irgen::emitImpliedWitnessTableRef(swift::irgen::IRGenFunction&, llvm::ArrayRef<swift::irgen::ProtocolEntry>, swift::ProtocolDecl*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 210
5  swift                    0x0000000109c49575 swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 1925
6  swift                    0x0000000109d63556 swift::irgen::emitWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanType, llvm::Value**, swift::ProtocolConformanceRef) + 102
7  swift                    0x0000000109d6d66e swift::irgen::emitGenericRequirementFromSubstitutions(swift::irgen::IRGenFunction&, swift::CanGenericSignature, swift::ModuleDecl&, swift::irgen::GenericRequirement, swift::SubstitutionMap const&) + 270
8  swift                    0x0000000109d6d4c1 void llvm::function_ref<void (swift::irgen::GenericRequirement)>::callback_fn<(anonymous namespace)::EmitPolymorphicArguments::emit(swift::SubstitutionMap const&, swift::irgen::WitnessMetadata*, swift::irgen::Explosion&)::$_23>(long, swift::irgen::GenericRequirement) + 33
9  swift                    0x0000000109d6b1b2 void llvm::function_ref<void (swift::irgen::GenericRequirement)>::callback_fn<(anonymous namespace)::PolymorphicConvention::enumerateUnfulfilledRequirements(llvm::function_ref<void (swift::irgen::GenericRequirement)> const&)::$_12>(long, swift::irgen::GenericRequirement) + 162
10 swift                    0x0000000109d5e60b swift::irgen::enumerateGenericSignatureRequirements(swift::CanGenericSignature, llvm::function_ref<void (swift::irgen::GenericRequirement)> const&) + 267
11 swift                    0x0000000109d6d279 swift::irgen::emitPolymorphicArguments(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::SILFunctionType>, swift::SubstitutionMap const&, swift::irgen::WitnessMetadata*, swift::irgen::Explosion&) + 457
12 swift                    0x0000000109deb471 (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 2737
13 swift                    0x0000000109dc9d41 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 9825
14 swift                    0x0000000109cab910 swift::irgen::IRGenerator::emitGlobalTopLevel(bool) + 1184
15 swift                    0x0000000109daa386 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) + 1382
16 swift                    0x0000000109bea980 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 46928
17 swift                    0x0000000109bdbd35 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7717
18 swift                    0x0000000109b81965 main + 1349
19 libdyld.dylib            0x00007fff64dcaed9 start + 1
20 libdyld.dylib            0x000000000000000f start + 2602783031
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file CrashMeAmadeus.swift -target x86_64-apple-darwin18.2.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -O -module-name CrashMeAmadeus -o /var/folders/8x/3lp6lwkd3ds7w1qz1y5qt8x93mffrt/T/CrashMeAmadeus-748130.o 
1.  While emitting IR SIL function "@$S14CrashMeAmadeus22InternalBaseViewBridgeC16startCoordinatoryyF".
 for 'startCoordinator()' at CrashMeAmadeus.swift:19:5
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)

Removing AnyObject from InternalCoordinatorProtocol declaration avoids the crash.

Removing '-> Self' from InternalCoordinatorProtocol extension (and working around it) avoids the crash.

@belkadan
Copy link
Contributor

With asserts, on near-master:

Assertion failed: (conforms != equivClass->conformsTo.end()), function getConformanceAccessPath, file /Volumes/Data/swift-public/swift/lib/AST/GenericSignature.cpp, line 986.
Stack dump:
0.  Program arguments: /Volumes/Data/swift-public/build/ninja/swift-macosx-x86_64/bin/swift -frontend -c -primary-file - -target x86_64-apple-darwin18.6.0 -enable-objc-interop -sdk /Volumes/Data/Applications/Xcode11.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk -O -color-diagnostics -module-name main -o /var/folders/_d/dmrgv26d3bs6lkrks9z825_w0000gn/T/--389fc6.o 
1.  Swift version 5.1-dev (LLVM af1f73e9e9, Swift 92c07317ee)
2.  While emitting IR SIL function "@$s4main22InternalBaseViewBridgeC16startCoordinatoryyF".
 for 'startCoordinator()' (at <stdin>:19:5)
0  swift                    0x0000000110d7bae5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x0000000110d7ad65 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x0000000110d7c0c8 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff5b802b5d _sigtramp + 29
4  libsystem_platform.dylib 0x00007fe1c68195f4 _sigtramp + 1795254964
5  libsystem_c.dylib        0x00007fff5b6bc6a6 abort + 127
6  libsystem_c.dylib        0x00007fff5b68520d basename_r + 0
7  swift                    0x00000001111b7033 swift::GenericSignature::getConformanceAccessPath(swift::Type, swift::ProtocolDecl*) (.cold.2) + 35
8  swift                    0x000000010e2307cd swift::GenericSignature::getConformanceAccessPath(swift::Type, swift::ProtocolDecl*) + 1229
9  swift                    0x000000010d5605de swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 126
10 swift                    0x000000010d625d25 swift::irgen::emitWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanType, llvm::Value**, swift::ProtocolConformanceRef) + 149
11 swift                    0x000000010d626812 swift::irgen::emitGenericRequirementFromSubstitutions(swift::irgen::IRGenFunction&, swift::CanGenericSignature, swift::ModuleDecl&, swift::irgen::GenericRequirement, swift::SubstitutionMap) + 178

@belkadan
Copy link
Contributor

@swift-ci create

@slavapestov
Copy link
Member

No longer crashes on master, so I'm adding a regression test. #32610

@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 IRGen LLVM IR generation optimized only Flag: An issue whose reproduction requires optimized compilation
Projects
None yet
Development

No branches or pull requests

4 participants