Open
Description
Previous ID | SR-2088 |
Radar | None |
Original Reporter | @lorentey |
Type | Bug |
Environment
Apple Swift version 3.0 (swiftlang-800.0.33.1 clang-800.0.31)
Target: x86_64-apple-macosx10.9
Additional Detail from JIRA
Votes | 1 |
Component/s | Compiler |
Labels | Bug, 3.0Regression, CompilerCrash |
Assignee | None |
Priority | Medium |
md5: 97198e1f40402f93aee8b9e4b7924c8a
Issue Description:
The following code crashes the Swift 3 REPL, runner, and (in certain cases) the compiler.
import Foundation
extension Cache {
convenience init(foo: String) {
self.init()
}
}
swift test.swift
prints the following backtrace:
0 swift 0x000000010e12267b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x000000010e121966 llvm::sys::RunSignalHandlers() + 70
2 swift 0x000000010e122ccf SignalHandler(int) + 287
3 libsystem_platform.dylib 0x00007fffa7cd301a _sigtramp + 26
4 libsystem_platform.dylib 0x00007f81dfae70c0 _sigtramp + 937509056
5 swift 0x000000010bbc7687 swift::irgen::IRGenModule::emitRuntimeRegistration() + 3863
6 swift 0x000000010bc57114 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1364
7 swift 0x000000010bc55ecd swift::performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&) + 621
8 swift 0x000000010bb92bfa swift::RunImmediately(swift::CompilerInstance&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions const&) + 154
9 swift 0x000000010bb844ac performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 13788
10 swift 0x000000010bb7ffc2 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2898
11 swift 0x000000010bb4e014 main + 2884
12 libdyld.dylib 0x00007fffa7ac7255 start + 1
13 libdyld.dylib 0x000000000000000c start + 1481870776
Stack dump:
0. Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret /tmp/test.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -color-diagnostics -module-name test
fish: 'swift /tmp/test.swift' terminated by signal SIGSEGV (Address boundary error)
Interestingly, swiftc test.swift
does not crash, although the same code in an Xcode project does, with a different backtrace:
CompileSwift normal x86_64 /Users/lorentey/Git/CacheCrash/CacheCrash/Test.swift
cd /Users/lorentey/Git/CacheCrash
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/lorentey/Git/CacheCrash/CacheCrash/Test.swift -target x86_64-apple-macosx10.12 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -I /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Products/Debug -F /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Products/Debug -enable-testing -g -module-cache-path /Users/lorentey/Library/Developer/Xcode/DerivedData/ModuleCache -D DEBUG -serialize-debugging-options -Xcc -I/Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/CacheCrash-generated-files.hmap -Xcc -I/Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/CacheCrash-own-target-headers.hmap -Xcc -I/Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/CacheCrash-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/CacheCrash-project-headers.hmap -Xcc -I/Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Products/Debug/include -Xcc -I/Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/DerivedSources/x86_64 -Xcc -I/Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/lorentey/Git/CacheCrash -emit-module-doc-path /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/Objects-normal/x86_64/Test~partial.swiftdoc -Onone -parse-as-library -module-name CacheCrash -emit-module-path /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/Objects-normal/x86_64/Test~partial.swiftmodule -serialize-diagnostics-path /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/Objects-normal/x86_64/Test.dia -emit-dependencies-path /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/Objects-normal/x86_64/Test.d -emit-reference-dependencies-path /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/Objects-normal/x86_64/Test.swiftdeps -o /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/Objects-normal/x86_64/Test.o
0 swift 0x0000000109d2e67b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x0000000109d2d966 llvm::sys::RunSignalHandlers() + 70
2 swift 0x0000000109d2eccf SignalHandler(int) + 287
3 libsystem_platform.dylib 0x00007fffa7cd301a _sigtramp + 26
4 libsystem_platform.dylib 0x0000000000000400 _sigtramp + 1479726080
5 swift 0x0000000107814989 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType) + 73
6 swift 0x000000010784200d bool llvm::function_ref<bool (swift::Type)>::callback_fn<swift::Type::visit(llvm::function_ref<void (swift::Type)>) const::'lambda'(swift::Type)>(long, swift::Type) + 13
7 swift 0x0000000107f9ea0e swift::Type::findIf(llvm::function_ref<bool (swift::Type)>) const::Walker::walkToTypePre(swift::Type) + 14
8 swift 0x0000000107fa6820 swift::TypeVisitor<(anonymous namespace)::Traversal, bool>::visit(swift::Type) + 3728
9 swift 0x0000000107fa5946 swift::Type::walk(swift::TypeWalker&) const + 54
10 swift 0x0000000107f966e4 swift::Type::findIf(llvm::function_ref<bool (swift::Type)>) const + 36
11 swift 0x000000010788e2bc void (anonymous namespace)::IRGenSILFunction::emitDebugVariableDeclaration<llvm::Value*>(llvm::Value*, swift::irgen::DebugTypeInfo, swift::SILType, swift::SILDebugScope const*, llvm::StringRef, unsigned int, swift::irgen::IndirectionKind) + 140
12 swift 0x000000010788e213 (anonymous namespace)::IRGenSILFunction::emitDebugInfoForAllocStack(swift::AllocStackInst*, swift::irgen::TypeInfo const&, llvm::Value*) + 595
13 swift 0x0000000107881356 swift::SILVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::ValueBase*) + 358
14 swift 0x000000010787d80b swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 7275
15 swift 0x00000001077d5734 swift::irgen::IRGenerator::emitGlobalTopLevel() + 596
16 swift 0x000000010786302f performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1135
17 swift 0x0000000107863466 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, unsigned int) + 70
18 swift 0x000000010779056c performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 13980
19 swift 0x000000010778bfc2 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2898
20 swift 0x000000010775a014 main + 2884
21 libdyld.dylib 0x00007fffa7ac7255 start + 1
Stack dump:
0. Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/lorentey/Git/CacheCrash/CacheCrash/Test.swift -target x86_64-apple-macosx10.12 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -I /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Products/Debug -F /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Products/Debug -enable-testing -g -module-cache-path /Users/lorentey/Library/Developer/Xcode/DerivedData/ModuleCache -D DEBUG -serialize-debugging-options -Xcc -I/Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/CacheCrash-generated-files.hmap -Xcc -I/Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/CacheCrash-own-target-headers.hmap -Xcc -I/Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/CacheCrash-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/CacheCrash-project-headers.hmap -Xcc -I/Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Products/Debug/include -Xcc -I/Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/DerivedSources/x86_64 -Xcc -I/Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/lorentey/Git/CacheCrash -emit-module-doc-path /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/Objects-normal/x86_64/Test~partial.swiftdoc -Onone -parse-as-library -module-name CacheCrash -emit-module-path /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/Objects-normal/x86_64/Test~partial.swiftmodule -serialize-diagnostics-path /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/Objects-normal/x86_64/Test.dia -emit-dependencies-path /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/Objects-normal/x86_64/Test.d -emit-reference-dependencies-path /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/Objects-normal/x86_64/Test.swiftdeps -o /Users/lorentey/Library/Developer/Xcode/DerivedData/CacheCrash-afxvufwrcgkqmogcxmvfvseiiced/Build/Intermediates/CacheCrash.build/Debug/CacheCrash.build/Objects-normal/x86_64/Test.o
1. While emitting IR SIL function @_TFE10CacheCrashCSo5CachecfT3fooSS_GS0_xq__ for 'init' at /Users/lorentey/Git/CacheCrash/CacheCrash/Test.swift:12:17