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-5284] Reproducible segfault at swift::ModuleFile::getTypeChecked #47859

Closed
swift-ci opened this issue Jun 22, 2017 · 13 comments
Closed

[SR-5284] Reproducible segfault at swift::ModuleFile::getTypeChecked #47859

swift-ci opened this issue Jun 22, 2017 · 13 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 regression serialization Area → compiler: Serialization & deserialization swift 4.0

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5284
Radar rdar://problem/32926560
Original Reporter gwk (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

OSX 10.12...10.13b3; Xcode 9b1...9b3.

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.0Regression, CompilerCrash, Serialization
Assignee @belkadan
Priority Medium

md5: ca543f0c1a4225dd18f7cee68a6331e5

Issue Description:

Repro as follows; let me know if there is something more useful I can provide.

$ git clone git@github.com:gwk/quilt.git
$ cd quilt
$ git checkout 6aa7a62
$ swift build --build-path _build
Compile Swift Module 'QuiltBridge' (23 sources)
0  swift                    0x000000010c2f23aa PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010c2f17e6 SignalHandler(int) + 662
2  libsystem_platform.dylib 0x000000010d6ddb3a _sigtramp + 26
3  libsystem_platform.dylib 0x00007fff56faa250 _sigtramp + 1233962800
4  swift                    0x0000000109a15c6e swift::ModuleFile::getTypeChecked(llvm::PointerEmbeddedInt<unsigned int, 31>) + 686
5  swift                    0x0000000109a16fad swift::ModuleFile::getTypeChecked(llvm::PointerEmbeddedInt<unsigned int, 31>) + 5613
6  swift                    0x0000000109a0dad0 swift::ModuleFile::getDeclChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 18288
7  swift                    0x0000000109a09324 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 84
8  swift                    0x0000000109a09008 swift::ModuleFile::readParameterList() + 264
9  swift                    0x0000000109a11352 swift::ModuleFile::getDeclChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 32754
10 swift                    0x0000000109a21451 swift::ModuleFile::loadAllMembers(swift::Decl*, unsigned long long) + 657
11 swift                    0x0000000109e6b2a6 swift::IterableDeclContext::loadAllMembers() const + 134
12 swift                    0x0000000109ec4d1c swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 364
13 swift                    0x0000000109a1b61e swift::ModuleFile::resolveCrossReference(swift::ModuleDecl*, unsigned int) + 3294
14 swift                    0x0000000109a0cd65 swift::ModuleFile::getDeclChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 14853
15 swift                    0x0000000109a16a4d swift::ModuleFile::getTypeChecked(llvm::PointerEmbeddedInt<unsigned int, 31>) + 4237
16 swift                    0x0000000109a15c32 swift::ModuleFile::getTypeChecked(llvm::PointerEmbeddedInt<unsigned int, 31>) + 626
17 swift                    0x0000000109a0e96b swift::ModuleFile::getDeclChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 22027
18 swift                    0x0000000109a4279e swift::ModuleFile::getTopLevelDecls(llvm::SmallVectorImpl<swift::Decl*>&) + 1982
19 swift                    0x00000001096f1680 swift::SILPassManager::SILPassManager(swift::SILModule*, llvm::StringRef) + 1504
20 swift                    0x00000001096f7cff swift::runSILDiagnosticPasses(swift::SILModule&) + 143
21 swift                    0x0000000108cc40f0 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13696
22 swift                    0x0000000108cbf304 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7332
23 swift                    0x0000000108c75728 main + 12248
24 libdyld.dylib            0x000000010d423235 start + 1
25 libdyld.dylib            0x0000000000000032 start + 4072525310
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -emit-module /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CG-vec~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CGContext~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CGImage~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CGPath~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CGPoint-generated~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CGPoint~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CGRect~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CGSize~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CGVector-generated~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CGVector~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CRColor~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CREdgeInsets~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CREvent~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CRFont~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CRFontDescriptor~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CRResponder~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CRView~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CRViewController~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CRWindow~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/Flt~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/NSLayoutConstraint~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/QKResponder~partial.swiftmodule /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/layout~partial.swiftmodule -parse-as-library -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /Users/gwk/work/ploy/quilt/_build/debug -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/gwk/work/ploy/quilt/_build/debug/ModuleCache -swift-version 3 -D SWIFT_PACKAGE -emit-module-doc-path /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.swiftdoc -module-name QuiltBridge -o /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.swiftmodule 
1.  While reading from /Users/gwk/work/ploy/quilt/_build/debug/QuiltBridge.build/CRView~partial.swiftmodule
2.  While deserializing 'CRFlex' (TypeAliasDecl #&#8203;14) in 'QuiltBridge'
3.  While deserializing 'AutoresizingMask' (StructDecl #&#8203;6) in 'QuiltBridge'
4.  Cross-reference to module 'AppKit'
    ... NSView
    ... in an extension in module 'AppKit'
    ... AutoresizingMask
5.  While loading members for extension of NSView in module 'QuiltBridge'
6.  While deserializing 'init' (ConstructorDecl #&#8203;68) in 'QuiltBridge'
7.  While deserializing 'flex' (ParamDecl #&#8203;178) in 'QuiltBridge'
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: merge-module command failed due to signal 11 (use -v to see invocation)
error: terminated(1): /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/gwk/work/ploy/quilt/_build/debug.yaml
@belkadan
Copy link
Contributor

To confirm: this doesn't fail in Xcode 8.3?

@belkadan
Copy link
Contributor

@swift-ci create

@swift-ci
Copy link
Collaborator Author

Comment by George King (JIRA)

Yes, this code used to compile fine using the XCode 8.3.2 toolchain.

@swift-ci
Copy link
Collaborator Author

Comment by George King (JIRA)

I tried this on Xcode 9b2 and it fails in the same way.

@swift-ci
Copy link
Collaborator Author

Comment by George King (JIRA)

Still failing on Xcode 9b3.

@swift-ci
Copy link
Collaborator Author

Comment by George King (JIRA)

I have produced a minimal repro of the bug, attached here. Just running the single file under the swift interpreter exits cleanly, but building the package crashes similarly to the initial trace above. swift-crflex-bug.zip

@belkadan
Copy link
Contributor

Prospective fix at #10956

@belkadan
Copy link
Contributor

Follow-up work in #11018

@belkadan
Copy link
Contributor

4.0 branch: #11013

@belkadan
Copy link
Contributor

Merged into swift-4.0-branch, will be in a future Xcode release.

@swift-ci
Copy link
Collaborator Author

Comment by George King (JIRA)

I'm still seeing this crash after installing Xcode 9 beta4 and the corresponding command line tools. Did this fix not make it into that release?

$ swift --version
Apple Swift version 4.0 (swiftlang-900.0.54.11 clang-900.0.31)
Target: x86_64-apple-macosx10.9

@belkadan
Copy link
Contributor

It did not, sorry.

@swift-ci
Copy link
Collaborator Author

Comment by George King (JIRA)

OK, thanks - better than the alternative!

@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 regression serialization Area → compiler: Serialization & deserialization swift 4.0
Projects
None yet
Development

No branches or pull requests

3 participants