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-7002] Compiler crash when try to extend OptionSet with ExpressibleByIntegerLiteral #49550

Closed
krzyzanowskim opened this issue Feb 14, 2018 · 4 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 type checker Area → compiler: Semantic analysis

Comments

@krzyzanowskim
Copy link
Contributor

Previous ID SR-7002
Radar rdar://problem/37547005
Original Reporter @krzyzanowskim
Type Bug
Status Resolved
Resolution Done
Environment

Swift 4.0.3

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

md5: 6dd1255aba018996941dbd98a599c6fc

Issue Description:

struct Foo: OptionSet {
    let rawValue: Int
    static let none = Foo(rawValue: 1 << 0)
}

extension Foo: ExpressibleByIntegerLiteral { }
0  swift                    0x000000010b18536a PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010b1847a6 SignalHandler(int) + 662
2  libsystem_platform.dylib 0x00007fff73de3f5a _sigtramp + 26
3  swift                    0x000000010b14a530 void write_unsigned<unsigned long long>(llvm::raw_ostream&, unsigned long long, unsigned long, llvm::IntegerStyle, bool) + 304
4  swift                    0x000000010842dcf3 swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::visitProtocolDecl(swift::ProtocolDecl*) + 371
5  swift                    0x000000010842cb88 swift::Lowering::SILGenModule::getWitnessTable(swift::ProtocolConformance*) + 488
6  swift                    0x0000000108432230 swift::Lowering::SILGenModule::visitExtensionDecl(swift::ExtensionDecl*) + 608
7  swift                    0x000000010834f91b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1115
8  swift                    0x00000001083512a9 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool) + 841
9  swift                    0x0000000107ae1d06 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 12966
10 swift                    0x0000000107add1f4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7716
11 swift                    0x0000000107a91e78 main + 12248
12 libdyld.dylib            0x00007fff73b62115 start + 1
13 libdyld.dylib            0x000000000000000e start + 2353651450
Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file Untitled 47.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -module-name main -o /var/folders/dx/0spkn3yn4fzgf45zgk8nx8c40000gn/T/Untitled 47-d3977f.o
<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)
@jckarter
Copy link
Member

In a debug compiler:

extension of Foo is missing witness for ExpressibleByIntegerLiteral.init
0  swift                    0x00000001167a1dcc llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
1  swift                    0x00000001167a23c9 PrintStackTraceSignalHandler(void*) + 25
2  swift                    0x000000011679db89 llvm::sys::RunSignalHandlers() + 425
3  swift                    0x00000001167a2822 SignalHandler(int) + 354
4  libsystem_platform.dylib 0x00007fff7d119f5a _sigtramp + 26
5  libsystem_platform.dylib 0x000000012ba9b670 _sigtramp + 2929202992
6  libsystem_c.dylib        0x00007fff7cec41ae abort + 127
7  swift                    0x0000000111586a3a (anonymous namespace)::Verifier::verifyConformance(swift::Decl*, swift::ProtocolConformance*) + 2250
8  swift                    0x000000011158c4c0 (anonymous namespace)::Verifier::verifyChecked(swift::ExtensionDecl*) + 448
9  swift                    0x00000001115831d0 swift::ExtensionDecl* (anonymous namespace)::Verifier::dispatchVisitPost<swift::ExtensionDecl*>(swift::ExtensionDecl*) + 528
10 swift                    0x000000011154d6d5 (anonymous namespace)::Verifier::walkToDeclPost(swift::Decl*) + 1317
11 swift                    0x000000011158f1c7 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 167
12 swift                    0x000000011158f110 swift::Decl::walk(swift::ASTWalker&) + 64
13 swift                    0x000000011179970d swift::SourceFile::walk(swift::ASTWalker&) + 525
14 swift                    0x0000000111549926 swift::verify(swift::SourceFile&) + 150
15 swift                    0x0000000110f651db swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int) + 2027
16 swift                    0x00000001105d1d2e swift::CompilerInstance::parseAndTypeCheckMainFile(swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 926
17 swift                    0x00000001105cdcc9 swift::CompilerInstance::parseAndCheckTypes(swift::CompilerInstance::ImplicitImports const&) + 697
18 swift                    0x00000001105cd479 swift::CompilerInstance::performSema() + 1833
19 swift                    0x000000010ec87d06 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 646
20 swift                    0x000000010ec862be swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7406
21 swift                    0x000000010ebacaa2 main + 4834
22 libdyld.dylib            0x00007fff7ce18021 start + 1
Stack dump:
0.  Program arguments: /Users/jgroff/src/s/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift -frontend -interpret /Users/jgroff/foo.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -color-diagnostics -module-name foo 
1.  While walking into decl extension of Foo at /Users/jgroff/foo.swift:6:1
2.  While verifying protocol conformance extension of Foo at /Users/jgroff/foo.swift:6:1
Abort trap: 6

Looks like we're failing to diagnose the fact that Foo is missing requirements from ExpressibleByIntegerLiteral, or failing to check the conformance at all before proceeding to SILGen.

@jckarter
Copy link
Member

@swift-ci create

@mdiep
Copy link
Contributor

mdiep commented Jun 5, 2018

This no longer crashes in Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3.

7002.swift:6:1: error: type 'Foo' does not conform to protocol 'ExpressibleByIntegerLiteral'
extension Foo: ExpressibleByIntegerLiteral { }
^
Swift.ExpressibleByIntegerLiteral:2:20: note: protocol requires nested type 'IntegerLiteralType'; do you want to add it?
    associatedtype IntegerLiteralType : _ExpressibleByBuiltinIntegerLiteral
                   ^

@DougGregor
Copy link
Member

Confirmed that this is fixed with 4.2.

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

5 participants