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-3889] Swift compiler crashes with -O option #46474

Closed
swift-ci opened this issue Feb 7, 2017 · 4 comments
Closed

[SR-3889] Swift compiler crashes with -O option #46474

swift-ci opened this issue Feb 7, 2017 · 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 optimized only Flag: An issue whose reproduction requires optimized compilation

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Feb 7, 2017

Previous ID SR-3889
Radar None
Original Reporter Okui (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Xcode 8.2.1 on Mac OS X 10.12.2 Sierra

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

md5: df18e9a29d2285920bb697e039f6ae95

duplicates:

  • SR-3853 Compiler segfault when compiling tests and using a class from another framework and extending a superclass of that class with a convenience init in another file

Issue Description:

I have a code that can be compiled with as Mac app, or as iOS simulator, but crash when building for iOS (ARM target)

Here's swift compiler log. Tested both Xcode 8.2.1 and Xcode 8.3 beta 2. Even with latest swift build (https://swift.org/builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2017-02-06-a/swift-DEVELOPMENT-SNAPSHOT-2017-02-06-a-osx.pkg) crashes.

The log says something about NSNumber, but the code itself does not do anything with NSNumber directly.

CompileSwift normal arm64 /Users/kaz/work/Nucleator/Flinto/Views/PathLayerView.swift
    cd /Users/kaz/work/Nucleator
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -filelist /var/folders/1d/cccqfqp13b55kz02c5gx2dbm0000gp/T/sources-87afc9 -primary-file /Users/kaz/work/Nucleator/Flinto/Views/PathLayerView.swift -target arm64-apple-ios9.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk -I /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Products/Profile-iphoneos -F /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Products/Profile-iphoneos -F /Users/kaz/work/Nucleator/FlintoViewer -enable-testing -g -import-objc-header /Users/kaz/work/Nucleator/FlintoViewer/Flinto-Bridging-Header-iOS.h -module-cache-path /Users/kaz/work/Nucleator/DerivedData/ModuleCache -D DEBUG -serialize-debugging-options -Xcc -I/Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Flinto-generated-files.hmap -Xcc -I/Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Flinto-own-target-headers.hmap -Xcc -I/Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Flinto-all-target-headers.hmap -Xcc -iquote -Xcc /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Flinto-project-headers.hmap -Xcc -I/Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Products/Profile-iphoneos/include -Xcc -I/Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/DerivedSources/arm64 -Xcc -I/Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DDEBUG=1 -Xcc -working-directory/Users/kaz/work/Nucleator -emit-module-doc-path /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Objects-normal/arm64/PathLayerView~partial.swiftdoc -O -module-name Flinto -emit-module-path /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Objects-normal/arm64/PathLayerView~partial.swiftmodule -serialize-diagnostics-path /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Objects-normal/arm64/PathLayerView.dia -emit-dependencies-path /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Objects-normal/arm64/PathLayerView.d -emit-reference-dependencies-path /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Objects-normal/arm64/PathLayerView.swiftdeps -o /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Objects-normal/arm64/PathLayerView.o

0  swift                    0x000000010a3c73ad PrintStackTraceSignalHandler(void*) + 45
1  swift                    0x000000010a3c6b56 SignalHandler(int) + 790
2  libsystem_platform.dylib 0x00007fffd2a95bba _sigtramp + 26
3  libsystem_platform.dylib 0x00007fff58897968 _sigtramp + 2246057416
4  swift                    0x0000000107e1b3fa swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 5034
5  swift                    0x0000000107accc3d (anonymous namespace)::SwiftDeclConverter::recordObjCOverride(swift::AbstractFunctionDecl*) + 253
6  swift                    0x0000000107acfa98 (anonymous namespace)::SwiftDeclConverter::importConstructor(clang::ObjCMethodDecl const*, swift::DeclContext*, bool, llvm::Optional<swift::CtorInitializerKind>, bool, swift::ObjCSelector, swift::ClangImporter::Implementation::ImportedName, llvm::ArrayRef<clang::ParmVarDecl const*>, bool, bool&) + 9096
7  swift                    0x0000000107ab4221 (anonymous namespace)::SwiftDeclConverter::VisitObjCMethodDecl(clang::ObjCMethodDecl const*, swift::DeclContext*, bool) + 12577
8  swift                    0x0000000107aa578b clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3547
9  swift                    0x0000000107aa3fdc swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool, bool) + 828
10 swift                    0x0000000107ad45e2 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 354
11 swift                    0x0000000107ad32e2 swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 2066
12 swift                    0x0000000107e1cdea swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 138
13 swift                    0x0000000107e1b023 swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 4051
14 swift                    0x0000000107ab5148 (anonymous namespace)::SwiftDeclConverter::VisitObjCPropertyDecl(clang::ObjCPropertyDecl const*, swift::DeclContext*) + 360
15 swift                    0x0000000107aa576f clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3519
16 swift                    0x0000000107aa3fdc swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool, bool) + 828
17 swift                    0x0000000107ad45e2 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 354
18 swift                    0x0000000107ad32e2 swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 2066
19 swift                    0x0000000107e1cdea swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 138
20 swift                    0x0000000107ace250 (anonymous namespace)::SwiftDeclConverter::importConstructor(clang::ObjCMethodDecl const*, swift::DeclContext*, bool, llvm::Optional<swift::CtorInitializerKind>, bool, swift::ObjCSelector, swift::ClangImporter::Implementation::ImportedName, llvm::ArrayRef<clang::ParmVarDecl const*>, bool, bool&) + 2880
21 swift                    0x0000000107acc6d0 (anonymous namespace)::SwiftDeclConverter::importConstructor(clang::ObjCMethodDecl const*, swift::DeclContext*, bool, llvm::Optional<swift::CtorInitializerKind>, bool) + 880
22 swift                    0x0000000107ab1159 (anonymous namespace)::SwiftDeclConverter::VisitObjCMethodDecl(clang::ObjCMethodDecl const*, swift::DeclContext*, bool) + 89
23 swift                    0x0000000107aa578b clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3547
24 swift                    0x0000000107aa3fdc swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool, bool) + 828
25 swift                    0x0000000107ad45e2 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 354
26 swift                    0x0000000107ad32e2 swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 2066
27 swift                    0x0000000107962286 swift::Projection::getFirstLevelProjections(swift::SILType, swift::SILModule&, llvm::SmallVectorImpl<swift::Projection>&) + 966
28 swift                    0x00000001076a7dc4 swift::TypeExpansionAnalysis::getTypeExpansion(swift::SILType, swift::SILModule*) + 1444
29 swift                    0x00000001076f8a66 swift::LSLocation::expand(swift::LSLocation, swift::SILModule*, llvm::SmallVector<swift::LSLocation, 8u>&, swift::TypeExpansionAnalysis*) + 182
30 swift                    0x00000001076f971c swift::LSLocation::enumerateLSLocation(swift::SILModule*, swift::SILValue, std::__1::vector<swift::LSLocation, std::__1::allocator<swift::LSLocation> >&, llvm::SmallDenseMap<swift::LSLocation, unsigned int, 32u, llvm::DenseMapInfo<swift::LSLocation>, llvm::detail::DenseMapPair<swift::LSLocation, unsigned int> >&, llvm::DenseMap<swift::SILValue, swift::LSLocation, llvm::DenseMapInfo<swift::SILValue>, llvm::detail::DenseMapPair<swift::SILValue, swift::LSLocation> >&, swift::TypeExpansionAnalysis*) + 1004
31 swift                    0x00000001076fad9c swift::LSLocation::enumerateLSLocations(swift::SILFunction&, std::__1::vector<swift::LSLocation, std::__1::allocator<swift::LSLocation> >&, llvm::SmallDenseMap<swift::LSLocation, unsigned int, 32u, llvm::DenseMapInfo<swift::LSLocation>, llvm::detail::DenseMapPair<swift::LSLocation, unsigned int> >&, llvm::DenseMap<swift::SILValue, swift::LSLocation, llvm::DenseMapInfo<swift::SILValue>, llvm::detail::DenseMapPair<swift::SILValue, swift::LSLocation> >&, swift::TypeExpansionAnalysis*, std::__1::pair<int, int>&) + 204
32 swift                    0x00000001077f6c8b (anonymous namespace)::RedundantLoadElimination::run() + 1483
33 swift                    0x000000010772789e swift::SILPassManager::runOneIteration() + 5166
34 swift                    0x000000010772d1f6 swift::runSILOptimizationPasses(swift::SILModule&) + 3462
35 swift                    0x00000001073d40e2 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 20114
36 swift                    0x00000001073cd2b3 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17859
37 swift                    0x00000001073895cf main + 8239
38 libdyld.dylib            0x00007fffd2888255 start + 1
39 libdyld.dylib            0x0000000000000046 start + 762805746
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -filelist /var/folders/1d/cccqfqp13b55kz02c5gx2dbm0000gp/T/sources-87afc9 -primary-file /Users/kaz/work/Nucleator/Flinto/Views/PathLayerView.swift -target arm64-apple-ios9.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk -I /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Products/Profile-iphoneos -F /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Products/Profile-iphoneos -F /Users/kaz/work/Nucleator/FlintoViewer -enable-testing -g -import-objc-header /Users/kaz/work/Nucleator/FlintoViewer/Flinto-Bridging-Header-iOS.h -module-cache-path /Users/kaz/work/Nucleator/DerivedData/ModuleCache -D DEBUG -serialize-debugging-options -Xcc -I/Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Flinto-generated-files.hmap -Xcc -I/Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Flinto-own-target-headers.hmap -Xcc -I/Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Flinto-all-target-headers.hmap -Xcc -iquote -Xcc /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Flinto-project-headers.hmap -Xcc -I/Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Products/Profile-iphoneos/include -Xcc -I/Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/DerivedSources/arm64 -Xcc -I/Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DDEBUG=1 -Xcc -working-directory/Users/kaz/work/Nucleator -emit-module-doc-path /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Objects-normal/arm64/PathLayerView~partial.swiftdoc -O -module-name Flinto -emit-module-path /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Objects-normal/arm64/PathLayerView~partial.swiftmodule -serialize-diagnostics-path /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Objects-normal/arm64/PathLayerView.dia -emit-dependencies-path /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Objects-normal/arm64/PathLayerView.d -emit-reference-dependencies-path /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Objects-normal/arm64/PathLayerView.swiftdeps -o /Users/kaz/work/Nucleator/DerivedData/Flinto/Build/Intermediates/Flinto.build/Profile-iphoneos/FlintoViewer.build/Objects-normal/arm64/PathLayerView.o 
1.  While running pass #&#8203;11511 SILFunctionTransform "SIL Redundant Load Elimination" on SILFunction "@_TTSg5GVs22_ContiguousArrayBufferCSo8NSNumber_GS_S0__s10Collections___TFs32_copyCollectionToContiguousArrayuRxs10CollectionrFxGVs15ContiguousArrayWx8Iterator7Element__".
2.  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSValue.h:40:12: loading members for 'NSNumber'
3.  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSValue.h:42:1: importing 'NSNumber::initWithCoder:'
4.  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSDecimalNumber.h:143:12: loading members for 'NSDecimalNumberExtensions'
5.  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSDecimalNumber.h:145:32: importing 'NSDecimalNumberExtensions::decimalValue'
6.  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSValue.h:85:12: loading members for 'NSNumberCreation'
7.  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSValue.h:87:1: importing 'NSNumberCreation::numberWithChar:'
@swift-ci
Copy link
Collaborator Author

swift-ci commented Feb 7, 2017

Comment by Kaz Okui (JIRA)

Found the cause of the line. Actually, it was involved with NSNumber.

let layer = CAShapeLayer()
layer.lineDashPattern = pathLayer.style.border.dashPattern as? [NSNumber]

where pathLayer.style.border.dashPattern is Array of Double. I had to rewrite this to

layer.lineDashPattern = pathLayer.style.border.dashPattern.map { NSNumber(CGFloat($0)) }

But still, compiler should not crash, and the same code can pass on x86 compiler.

@belkadan
Copy link
Contributor

belkadan commented Feb 8, 2017

I might have just fixed this yesterday. When there's a newer snapshot than 2016-02-06, can you try again?

@swift-ci
Copy link
Collaborator Author

swift-ci commented Feb 8, 2017

@swift-ci
Copy link
Collaborator Author

Comment by Alexey Gordeev (JIRA)

Okui (JIRA User) , can you clarify please, is that error occurred in the last processed file (PathLayerView according to logs) or in another one?

I've got an error which looks the same but can't localize the file which causes this error.

@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 optimized only Flag: An issue whose reproduction requires optimized compilation
Projects
None yet
Development

No branches or pull requests

3 participants