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-7951] Making A Type Private Crashes the Compiler #50486

Closed
swift-ci opened this issue Jun 10, 2018 · 10 comments
Closed

[SR-7951] Making A Type Private Crashes the Compiler #50486

swift-ci opened this issue Jun 10, 2018 · 10 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

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-7951
Radar rdar://problem/41022050
Original Reporter zachrwolfe (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 10 Beta 1, macOS High Sierra 10.13.5, Swift 4.2. Debug mode.

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

md5: d0d48fb60f2abf66fb9fb4a73533e5da

duplicates:

  • SR-7923 Compiler crash when initializing a type from another module which contains a fileprivate member

Issue Description:

My project is able to crash the compiler. It seems to be related to my type Pointer, which the error message complained about. When the type was private, the compiler crashed; I made it public (as you'll see it on GitHub), and it compiles just fine.

Below is the crash log.

Global is external, but doesn't have external or weak linkage!

%swift.metadata_response (i64, %swift.type*)* @"$S6Parser7Pointer33_21BA051FFAB01C2E2FAA7AB01463B19FLLOMa"
:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log
:0: note: Broken module found, compilation aborted!
0 swift 0x000000010bfe8c5a PrintStackTraceSignalHandler(void*) + 42
1 swift 0x000000010bfe8066 SignalHandler(int) + 966
2 libsystem_platform.dylib 0x00007fff5206cf5a _sigtramp + 26
3 libsystem_platform.dylib 0x000000010ebb12c4 _sigtramp + 3165930372
4 libsystem_c.dylib 0x00007fff51e0a1ae abort + 127
5 swift 0x00000001082bae39 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)::$_1::__invoke(void*, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, bool) + 521
6 swift 0x000000010bf9bec8 llvm::report_fatal_error(llvm::Twine const&, bool) + 280
7 swift 0x000000010bf9bdab llvm::report_fatal_error(char const*, bool) + 43
8 swift 0x000000010bf63c0c (anonymous namespace)::VerifierLegacyPass::doFinalization(llvm::Module&) + 204
9 swift 0x000000010bf0a0f3 llvm::FPPassManager::doFinalization(llvm::Module&) + 83
10 swift 0x000000010bf0f4e7 llvm::legacy::FunctionPassManagerImpl::doFinalization(llvm::Module&) + 71
11 swift 0x0000000108476a85 swift::performLLVM(swift::IRGenOptions&, swift::DiagnosticEngine*, llvm::sys::SmartMutex, llvm::GlobalVariable, llvm::Module*, llvm::TargetMachine*, swift::version::Version const&, llvm::StringRef, swift::UnifiedStatsReporter*) + 5237
12 swift 0x00000001082c75c5 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 49093
13 swift 0x00000001082b810f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7839
14 swift 0x0000000108261c48 main + 13144
15 libdyld.dylib 0x00007fff51d5e015 start + 1
16 libdyld.dylib 0x000000000000005a start + 2921996358
Stack dump:
0. Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/CLIHeader.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/COFFFileHeader.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/DLLCharacteristics.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/HeapOnDiskOffsets.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/HeapSizes.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/MetadataRoot.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/MetadataTableStructure.swift -primary-file /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/MetadataTables.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/OptionSet+Count.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/OptionalHeader.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/Parser.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/Pointers.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/SectionCharacteristics.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/SectionHeader.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/SignatureBlobs.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/Stream.swift -primary-file /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/StreamHeaderGroup.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/Subsystem.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/TableIndexTypes.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/WinMDFile.swift -emit-module-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/MetadataTablespartial.swiftmodule -emit-module-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/StreamHeaderGrouppartial.swiftmodule -emit-module-doc-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/MetadataTablespartial.swiftdoc -emit-module-doc-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/StreamHeaderGrouppartial.swiftdoc -serialize-diagnostics-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/MetadataTables.dia -serialize-diagnostics-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/StreamHeaderGroup.dia -emit-dependencies-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/MetadataTables.d -emit-dependencies-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/StreamHeaderGroup.d -emit-reference-dependencies-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/MetadataTables.swiftdeps -emit-reference-dependencies-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/StreamHeaderGroup.swiftdeps -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Products/Debug -F /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Products/Debug -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D Xcode -serialize-debugging-options -Xcc -working-directory -Xcc /Users/zachwolfe/Documents/SwiftWinRT -Xcc -I/Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/swift-overrides.hmap -Xcc -I/Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Products/Debug/include -Xcc -I/Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/DerivedSources/x86_64 -Xcc -I/Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/DerivedSources -module-name Parser -o /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/MetadataTables.o -o /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/StreamHeaderGroup.o -index-store-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Index/DataStore -index-system-modules
error: Abort trap: 6

@belkadan
Copy link
Contributor

@swift-ci create

@bob-wilson
Copy link

This looks like a duplicate of https://bugs.swift.org/browse/SR-7923

@bob-wilson
Copy link

Zach, can you try a more recent 4.2 snapshot from swift.org and confirm that it is fixed now?

@swift-ci
Copy link
Collaborator Author

Comment by Zach Wolfe (JIRA)

Thanks Bob. That looks like my bug to me, but I’ll try out the latest snapshot tonight and report back here

@swift-ci
Copy link
Collaborator Author

Comment by Zach Wolfe (JIRA)

Actually the crash still occurs on the latest 4.2 snapshot available on swift.org.

Global is external, but doesn't have external or weak linkage!
%swift.metadata_response (i64, %swift.type*)* @"$S6Parser7Pointer33_21BA051FFAB01C2E2FAA7AB01463B19FLLOMa"
:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log
:0: note: Broken module found, compilation aborted!
0 swift 0x0000000108d2f2c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x0000000108d2e507 llvm::sys::RunSignalHandlers() + 39
2 swift 0x0000000108d2f942 SignalHandler(int) + 258
3 libsystem_platform.dylib 0x00007fff5206cf5a _sigtramp + 26
4 libsystem_platform.dylib 0x00000001104a4608 _sigtramp + 3192092360
5 libsystem_c.dylib 0x00007fff51e0a1ae abort + 127
6 swift 0x0000000105524fb9 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)::$_1::__invoke(void*, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, bool) + 521
7 swift 0x0000000108cce39c llvm::report_fatal_error(llvm::Twine const&, bool) + 252
8 swift 0x0000000108cce29b llvm::report_fatal_error(char const*, bool) + 43
9 swift 0x0000000108c7f234 (anonymous namespace)::VerifierLegacyPass::doFinalization(llvm::Module&) + 212
10 swift 0x0000000108c0f290 llvm::FPPassManager::doFinalization(llvm::Module&) + 80
11 swift 0x0000000108c0e9eb llvm::legacy::FunctionPassManagerImpl::doFinalization(llvm::Module&) + 107
12 swift 0x0000000105686d08 swift::performLLVMOptimizations(swift::IRGenOptions&, llvm::Module*, llvm::TargetMachine*) + 1400
13 swift 0x00000001056878c7 swift::performLLVM(swift::IRGenOptions&, swift::DiagnosticEngine*, llvm::sys::SmartMutex, llvm::GlobalVariable, llvm::Module*, llvm::TargetMachine*, swift::version::Version const&, llvm::StringRef, swift::UnifiedStatsReporter*) + 2023
14 swift 0x0000000105524935 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 16213
15 swift 0x000000010551f9bc swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2972
16 swift 0x00000001054db49e main + 2334
17 libdyld.dylib 0x00007fff51d5e015 start + 1
18 libdyld.dylib 0x000000000000003d start + 2921996329
Stack dump:
0. Program arguments: /Library/Developer/Toolchains/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-10-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/Metadata.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/Pointers.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/SignatureBlobs.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/Stream.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/TableIndexes.swift /Users/zachwolfe/Documents/SwiftWinRT/Sources/Parser/WinMDFile.swift -emit-module-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/Metadatapartial.swiftmodule -emit-module-doc-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/Metadatapartial.swiftdoc -serialize-diagnostics-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/Metadata.dia -emit-dependencies-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/Metadata.d -emit-reference-dependencies-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/Metadata.swiftdeps -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Products/Debug -F /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Products/Debug -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D Xcode -serialize-debugging-options -Xcc -I/Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/swift-overrides.hmap -Xcc -I/Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Products/Debug/include -Xcc -I/Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/DerivedSources/x86_64 -Xcc -I/Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/DerivedSources -Xcc -working-directory/Users/zachwolfe/Documents/SwiftWinRT -module-name Parser -o /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Build/Intermediates.noindex/swiftwinrt.build/Debug/Parser.build/Objects-normal/x86_64/Metadata.o -index-store-path /Users/zachwolfe/Library/Developer/Xcode/DerivedData/swiftwinrt-gxwdwyhzrdztayfaimlkjrkddsbf/Index/DataStore -index-system-modules
error: Abort trap: 6

@bob-wilson
Copy link

OK. Arnold, can you take a look to see if there's something different about this case?

@swift-ci
Copy link
Collaborator Author

Comment by Zach Wolfe (JIRA)

Just a heads up, the type in question has been deleted in master. So to repro you'll want to grab 43d1d1f or earlier.

@aschwaighofer
Copy link
Member

The change went into swift-4.2-branch yesterday morning. Maybe the snapshot you tried did not have the fix yet.

I tried with the following snapshot today (it has the necessary change) and both `swift build` and `swift build -c release` work without a trap

$ /Library/Developer/Toolchains/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-11-a.xctoolchain/usr/bin/swiftc -v
Apple Swift version 4.2-dev (LLVM a38ff55b31, Clang 5272858825, Swift d99cd32)
Target: x86_64-apple-darwin17.6.0

I tried the repo at:
$ git lg -1

  • 43d1d1f (HEAD) Reduce the number of files in the project by more than half, + nest all the things.

@aschwaighofer
Copy link
Member

Fixed in the current snapshot or later.

@swift-ci
Copy link
Collaborator Author

Comment by Zach Wolfe (JIRA)

Oh, okay. Thanks Arnold.

@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
Projects
None yet
Development

No branches or pull requests

5 participants