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-11098] swiftc segfault when compiling in release mode #53493

Closed
Frizlab opened this issue Jul 10, 2019 · 7 comments
Closed

[SR-11098] swiftc segfault when compiling in release mode #53493

Frizlab opened this issue Jul 10, 2019 · 7 comments
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

@Frizlab
Copy link

Frizlab commented Jul 10, 2019

Previous ID SR-11098
Radar rdar://52953078
Original Reporter @Frizlab
Type Bug
Status Closed
Resolution Duplicate
Environment

Tested on macOS with Swift 5.0.1 and 5.1 (swiftlang-1100.0.212.5 clang-1100.0.28.2), and on Linux with Swift 4.2.1.

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

md5: 39d19eb2ea75fefab810e98ddc4e4073

duplicates:

  • SR-4206 Override checking does not properly enforce requirements

Issue Description:

The following project crashes when compiled with the the -c release option:

https://gitlab.com/frizlab-demo-projects/swift-erasure-crash

Here’s the stack dump.

Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/frizlab/Desktop/test_crash/Sources/test_crash/ErasureChild.swift /Users/frizlab/Desktop/test_crash/Sources/test_crash/ErasureParent.swift /Users/frizlab/Desktop/test_crash/Sources/test_crash/Implementation.swift /Users/frizlab/Desktop/test_crash/Sources/test_crash/Protocol.swift /Users/frizlab/Desktop/test_crash/Sources/test_crash/main.swift -supplementary-output-file-map /var/folders/5j/7jfjtgkx7yg9qp9bpt33q0hm0000gn/T/supplementaryOutputs-b25cfc -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -I /Users/frizlab/Desktop/test_crash/.build/x86_64-apple-macosx/release -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -module-cache-path /Users/frizlab/Desktop/test_crash/.build/x86_64-apple-macosx/release/ModuleCache -swift-version 4.2 -O -D SWIFT_PACKAGE -color-diagnostics -module-name test_crash -num-threads 8 -o /Users/frizlab/Desktop/test_crash/.build/x86_64-apple-macosx/release/test_crash.build/ErasureChild.swift.o -o /Users/frizlab/Desktop/test_crash/.build/x86_64-apple-macosx/release/test_crash.build/ErasureParent.swift.o -o /Users/frizlab/Desktop/test_crash/.build/x86_64-apple-macosx/release/test_crash.build/Implementation.swift.o -o /Users/frizlab/Desktop/test_crash/.build/x86_64-apple-macosx/release/test_crash.build/Protocol.swift.o -o /Users/frizlab/Desktop/test_crash/.build/x86_64-apple-macosx/release/test_crash.build/main.swift.o 
1.  While emitting IR SIL function "@$s10test_crash9AnyParentC7unboxedxSgyAA0D8ProtocolRzlF".
 for 'unboxed()' (at /Users/frizlab/Desktop/test_crash/Sources/test_crash/ErasureParent.swift:29:9)
0  swift                    0x000000010c5c2c83 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x000000010c5c2456 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff70ec7b5d _sigtramp + 29
3  swift                    0x00000001091b4e71 swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const + 49
4  swift                    0x00000001083db137 swift::irgen::emitWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanType, llvm::Value**, swift::ProtocolConformanceRef) + 311
5  swift                    0x00000001083e2d40 swift::irgen::emitGenericRequirementFromSubstitutions(swift::irgen::IRGenFunction&, swift::CanGenericSignature, swift::ModuleDecl&, swift::irgen::GenericRequirement, swift::SubstitutionMap) + 256
6  swift                    0x00000001083e2ba4 void llvm::function_ref<void (swift::irgen::GenericRequirement)>::callback_fn<(anonymous namespace)::EmitPolymorphicArguments::emit(swift::SubstitutionMap, swift::irgen::WitnessMetadata*, swift::irgen::Explosion&)::$_21>(long, swift::irgen::GenericRequirement) + 36
7  swift                    0x00000001083e0a3d void llvm::function_ref<void (swift::irgen::GenericRequirement)>::callback_fn<(anonymous namespace)::PolymorphicConvention::enumerateUnfulfilledRequirements(llvm::function_ref<void (swift::irgen::GenericRequirement)> const&)::$_11>(long, swift::irgen::GenericRequirement) + 205
8  swift                    0x00000001083e094f (anonymous namespace)::PolymorphicConvention::enumerateUnfulfilledRequirements(llvm::function_ref<void (swift::irgen::GenericRequirement)> const&) + 319
9  swift                    0x00000001083e2925 swift::irgen::emitPolymorphicArguments(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::SILFunctionType>, swift::SubstitutionMap, swift::irgen::WitnessMetadata*, swift::irgen::Explosion&) + 485
10 swift                    0x000000010846b503 (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 2019
11 swift                    0x000000010844bbfa swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 9866
12 swift                    0x00000001082f9360 swift::irgen::IRGenerator::emitGlobalTopLevel() + 1616
13 swift                    0x00000001084267cc swift::performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, llvm::GlobalVariable**) + 1676
14 swift                    0x0000000108216da1 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 36993
15 swift                    0x000000010820a474 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6868
16 swift                    0x0000000108198fb3 main + 1219
17 libdyld.dylib            0x00007fff70cdc3d5 start + 1
18 libdyld.dylib            0x0000000000000029 start + 2402434133
@theblixguy
Copy link
Collaborator

You can work around it in the meantime by disabling the speculative devirtualization optimisation pass:

swift build -c release -Xswiftc "-Xllvm" -Xswiftc "-sil-disable-pass=specdevirt"

I don't think this is a bug with specdevirt though, but possibly an optimisation pass before it. cc @eeckstein

@eeckstein
Copy link
Member

cc aschwaighofer@apple.com (JIRA User)

@aschwaighofer
Copy link
Member

The problem is in the source and that the type checker allows this:

We have a covariant generic parameter type in a method override. This should not type check.

public protocol ChildProtocol : ParentProtocol {
}

public class AnyParent : ParentProtocol {

  public func unboxed<ParentType : ParentProtocol>() -> ParentType? {
  }
}

public class AnyChild : AnyParent, ChildProtocol {
  
=>  public override func unboxed<ChildType : ChildProtocol>() -> ChildType? {
  }

@aschwaighofer
Copy link
Member

Should be fixed by #24484

@Frizlab
Copy link
Author

Frizlab commented Jul 22, 2019

aschwaighofer@apple.com (JIRA User) Confirmed fixed in latest master nightly

@theblixguy
Copy link
Collaborator

Great![]( Could you make this issue as closed? Thanks)

@Frizlab
Copy link
Author

Frizlab commented Jul 22, 2019

Done! Sorry I did not know I had to close the issue as it was already marked Resolved 🙂

@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

5 participants