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-2169] When defining a typealias with a generic closure, the compiler segfaults: 11 when the closure is used in a different file as a parameter type. #44777

Closed
swift-ci opened this issue Jul 26, 2016 · 0 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 serialization Area → compiler: Serialization & deserialization

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-2169
Radar None
Original Reporter Andy (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

iMac Late 2012, 27'' Inch. El Capitan 10.11.6. Xcode 8, Beta 3 (8S174q)

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

md5: e0f43199afc129ed936e5b9aae276748

duplicates:

  • SR-1889 Compiler Segmentation Fault with Generic typealias declared in separate module

relates to:

  • SR-1889 Compiler Segmentation Fault with Generic typealias declared in separate module

Issue Description:

My apologies for the very poor title, it was hard to phrase. I will describe the exact issue here and I will provide the example project that can be simply open and run to see the segmentation fault: 11.

Consider you have the following typealias in a file called "Typealiases.swift":

public typealias APIResponseHandler<T> = (item: T?, error: ErrorProtocol?) -> Void

And then you want to use this typealias as a parameter type in a function in a different file. Let's call it "Functions.swift", and you have the following function there:

func bar(handler: APIResponseHandler<String>) {
    
}

As soon as you try to compile your project, the compiler will crash with a segmentation fault: 11, printing a stack trace similar to this:

0  swift                    0x0000000106feb28b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  swift                    0x0000000106fea576 llvm::sys::RunSignalHandlers() + 70
2  swift                    0x0000000106feb8df SignalHandler(int) + 287
3  libsystem_platform.dylib 0x00007fff97cbc52a _sigtramp + 26
4  libsystem_platform.dylib 0x00007fff5b200ae0 _sigtramp + 3277080016
5  swift                    0x0000000104ed87dd swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 2237
6  swift                    0x0000000104ed87a8 swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 2184
7  swift                    0x0000000104ed8d97 swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 3703
8  swift                    0x0000000104ed8326 swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 1030
9  swift                    0x0000000104ed84cf swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 1455
10 swift                    0x0000000104ed87bd swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 2205
11 swift                    0x0000000104ed8326 swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 1030
12 swift                    0x0000000104ed84cf swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 1455
13 swift                    0x0000000104ed6e57 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 26647
14 swift                    0x0000000104ef7c7b swift::ModuleFile::getTopLevelDecls(llvm::SmallVectorImpl<swift::Decl*>&) + 971
15 swift                    0x000000010523058f swift::ModuleDecl::getTopLevelDecls(llvm::SmallVectorImpl<swift::Decl*>&) const + 63
16 swift                    0x0000000104c0a47e swift::ClassHierarchyAnalysis::init() + 78
17 swift                    0x0000000104bffe61 swift::createClassHierarchyAnalysis(swift::SILModule*) + 129
18 swift                    0x0000000104c83889 swift::SILPassManager::SILPassManager(swift::SILModule*, llvm::StringRef) + 361
19 swift                    0x0000000104c8cf36 swift::runSILDiagnosticPasses(swift::SILModule&) + 118
20 swift                    0x0000000104a33cc7 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 11495
21 swift                    0x0000000104a300d2 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2898
22 swift                    0x00000001049fe154 main + 2884
23 libdyld.dylib            0x00007fff943c55ad start + 1
24 libdyld.dylib            0x0000000000000038 start + 1807985292
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -emit-module /Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/Objects-normal/x86_64/ViewController~partial.swiftmodule /Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/Objects-normal/x86_64/AppDelegate~partial.swiftmodule /Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/Objects-normal/x86_64/Typealiases~partial.swiftmodule /Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/Objects-normal/x86_64/Functions~partial.swiftmodule -parse-as-library -target x86_64-apple-ios10.0 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk -I /Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Products/Debug-iphonesimulator -F /Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/andyibanez/Library/Developer/Xcode/DerivedData/ModuleCache -D DEBUG -serialize-debugging-options -Xcc -I/Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/GenericTypealiasCrash-generated-files.hmap -Xcc -I/Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/GenericTypealiasCrash-own-target-headers.hmap -Xcc -I/Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/GenericTypealiasCrash-all-target-headers.hmap -Xcc -iquote -Xcc /Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/GenericTypealiasCrash-project-headers.hmap -Xcc -I/Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/DerivedSources/x86_64 -Xcc -I/Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/andyibanez/Desktop/GenericTypealiasCrash -emit-module-doc-path /Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/Objects-normal/x86_64/GenericTypealiasCrash.swiftdoc -module-name GenericTypealiasCrash -emit-objc-header-path /Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/Objects-normal/x86_64/GenericTypealiasCrash-Swift.h -o /Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/Objects-normal/x86_64/GenericTypealiasCrash.swiftmodule 
1.  While reading from /Users/andyibanez/Library/Developer/Xcode/DerivedData/GenericTypealiasCrash-cfblgyklzyfwrccrdsihgezhhihe/Build/Intermediates/GenericTypealiasCrash.build/Debug-iphonesimulator/GenericTypealiasCrash.build/Objects-normal/x86_64/Functions~partial.swiftmodule
2.  While deserializing 'bar' (FuncDecl #&#8203;1) 

Whoever, moving the typealias to the same file as the function (in this case, moving it to Functions.swift), the project compiles fine.

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

No branches or pull requests

2 participants