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-4022] Compiler crash when using inlines from Foundation in another framework #46605

Open
tjw opened this issue Feb 21, 2017 · 5 comments
Open

Comments

@tjw
Copy link
Contributor

@tjw tjw commented Feb 21, 2017

Previous ID SR-4022
Radar rdar://problem/30644829
Original Reporter @tjw
Type Bug

Attachment: Download

Environment

Xcode 8.3 beta 2 or beta 3

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

md5: 2e38afa90352057361aa20dab8a92a0c

Issue Description:

When using the Swift 3.1 compiler, attempts to use inline functions (particularly NSRange) can end up crashing the Swift compiler with something like:

1.	While running pass #​884 SILModuleTransform "Mandatory Inlining".
2.	While deserializing decl #​502 (XREF)in 'Foundation'
3.	Cross-reference to module 'Foundation'
	... NSMutableData
	... length
	... with type Int
4.	If you're seeing a crash here, check that your SDK and dependencies match the versions used to build 'Foundation'

Steps:
- Using Xcode 8.3 beta 2 or beta 3
- Extract the attached zip of source
- Open OmniGroup/Workspaces/OmniFrameworks.xcworkspace
- Build
- Build completes successfully
- Search for "Crashes compiler"
- Remove the #if false wrapper around any of the matches
- Build
- Compiler crashes

This code builds fine in Xcode 8.2.1.

0  swift                    0x000000010e34b7a7 PrintStackTraceSignalHandler(void\*) + 39
1  swift                    0x000000010e34ad36 SignalHandler(int) + 662
2  libsystem_platform.dylib 0x00007fffc1d0cbba _sigtramp + 26
3  libsystem_platform.dylib 0x0000000118f4f7ad _sigtramp + 1461988365
4  libsystem_c.dylib        0x00007fffc1b93420 abort + 129
5  swift                    0x000000010c0fcc45 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext\*>) + 38373
6  swift                    0x000000010c11a86f getSILDeclRef(swift::ModuleFile\*, llvm::ArrayRef<unsigned long long>, unsigned int&) + 47
7  swift                    0x000000010c110e93 swift::SILDeserializer::readSILInstruction(swift::SILFunction\*, swift::SILBasicBlock\*, swift::SILBuilder&, unsigned int, llvm::SmallVectorImpl<unsigned long long>&) + 2083
8  swift                    0x000000010c10fcb1 swift::SILDeserializer::readSILFunction(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction\*, llvm::StringRef, bool, bool) + 4785
9  swift                    0x000000010c11ae06 swift::SILDeserializer::lookupSILFunction(swift::SILFunction\*) + 422
10 swift                    0x000000010c0888fb swift::SILLinkerVisitor::processFunction(swift::SILFunction\*) + 299
11 swift                    0x000000010c0c50f5 swift::SILModule::linkFunction(swift::SILFunction\*, swift::SILOptions::LinkingMode) + 117
12 swift                    0x000000010bead6fb runOnFunctionRecursively(swift::SILFunction\*, swift::FullApplySite, swift::SILOptions::LinkingMode, llvm::DenseSet<swift::SILFunction\*, llvm::DenseMapInfo<swift::SILFunction\*> >&, llvm::ImmutableSet<swift::SILFunction\*, llvm::ImutContainerInfo<swift::SILFunction\*> >::Factory&, llvm::ImmutableSet<swift::SILFunction\*, llvm::ImutContainerInfo<swift::SILFunction\*> >, swift::ClassHierarchyAnalysis\*) + 3483
13 swift                    0x000000010beac727 (anonymous namespace)::MandatoryInlining::run() + 359
14 swift                    0x000000010be4bc0f swift::SILPassManager::runOneIteration() + 9903
15 swift                    0x000000010b71b81d swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 381
16 swift                    0x000000010be4ec07 swift::runSILDiagnosticPasses(swift::SILModule&) + 1591
17 swift                    0x000000010b5d25c2 swift::performFrontend(llvm::ArrayRef<char const\*>, char const\*, void\*, swift::FrontendObserver\*) + 46306
18 swift                    0x000000010b5823c2 main + 11298
19 libdyld.dylib            0x00007fffc1aff255 start + 1
20 libdyld.dylib            0x000000000000006e start + 1045433882
Stack dump:
0.	Program arguments: /Applications/Xcode-8.3-b3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/bungi/Source/Omni/20170221-Xcode83b2-InlineCrasher/OmniGroup/Frameworks/OmniFoundation/Crypto/OFCMSUtilities.swift /Users/bungi/Source/Omni/20170221-Xcode83b2-InlineCrasher/OmniGroup/Frameworks/OmniFoundation/FileManagement.subproj/OFDocumentEncryption.swift /Users/bungi/Source/Omni/20170221-Xcode83b2-InlineCrasher/OmniGroup/Frameworks/OmniFoundation/OFDiagnostics.swift /Users/bungi/Source/Omni/20170221-Xcode83b2-InlineCrasher/OmniGroup/Frameworks/OmniFoundation/FileManagement.subproj/OFUTI.swift /Users/bungi/Source/Omni/20170221-Xcode83b2-InlineCrasher/OmniGroup/Frameworks/OmniFoundation/OpenStepExtensions.subproj/NSProcessInfo-OFExtensions.swift /Users/bungi/Source/Omni/20170221-Xcode83b2-InlineCrasher/OmniGroup/Frameworks/OmniFoundation/OpenStepExtensions.subproj/NSBundle-OFExtensions.swift /Users/bungi/Source/Omni/20170221-Xcode83b2-InlineCrasher/OmniGroup/Frameworks/OmniFoundation/DataStructures.subproj/OFSelectionSet.swift /Users/bungi/Source/Omni/20170221-Xcode83b2-InlineCrasher/OmniGroup/Frameworks/OmniFoundation/CoreFoundationExtensions/SecItem-OFExtensions.swift /Users/bungi/Source/Omni/20170221-Xcode83b2-InlineCrasher/OmniGroup/Frameworks/OmniFoundation/FileManagement.subproj/OFDocumentEncryption-Inspection.swift /Users/bungi/Source/Omni/20170221-Xcode83b2-InlineCrasher/OmniGroup/Frameworks/OmniFoundation/OpenStepExtensions.subproj/NSLocking-OFExtensions.swift /Users/bungi/Source/Omni/20170221-Xcode83b2-InlineCrasher/OmniGroup/Frameworks/OmniFoundation/Bundle.swift -target x86_64-apple-macosx10.11 -enable-objc-interop -sdk /Applications/Xcode-8.3-b3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -I /Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Products/Debug -F /Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Products/Debug -application-extension -enable-testing -g -import-underlying-module -module-cache-path /Users/bungi/Library/Developer/Xcode/DerivedData/ModuleCache -D DEBUG -D DEBUG_bungi -D OMNI_BUILDING_FOR_MAC -D OMNI_BUILDING_FRAMEWORK_OR_BUNDLE -serialize-debugging-options -Xcc -I/Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/OmniFoundation-generated-files.hmap -Xcc -I/Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/OmniFoundation-own-target-headers.hmap -Xcc -I/Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/OmniFoundation-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/OmniFoundation-project-headers.hmap -Xcc -I/Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Products/Debug/include -Xcc -I/Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/DerivedSources -Xcc -I/Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Products/Debug -Xcc -I/Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/UninstalledProducts/macosx/include -Xcc -I/Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/UninstalledProducts/include -Xcc -I/Applications/Xcode-8.3-b3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2 -Xcc -I/Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/DerivedSources/x86_64 -Xcc -I/Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/DerivedSources -Xcc -DNS_BUILD_32_LIKE_64 -Xcc -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -Xcc -DOMNI_BUILD_IDENTIFIER_SUFFIX=@".Debug" -Xcc -DOMNI_BUILD_FILE_SUFFIX=@"-Debug" -Xcc -DDEBUG -Xcc -DDEBUG_bungi -Xcc -DOMNI_BUILDING_FOR_MAC -Xcc -DOMNI_BUILDING_FRAMEWORK_OR_BUNDLE -Xcc -ivfsoverlay -Xcc /Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/bungi/Source/Omni/20170221-Xcode83b2-InlineCrasher/OmniGroup/Frameworks/OmniFoundation -emit-module-doc-path /Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/Objects-normal/x86_64/OFCMSUtilities~partial.swiftdoc -Onone -module-name OmniFoundation -emit-module-path /Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/Objects-normal/x86_64/OFCMSUtilities~partial.swiftmodule -serialize-diagnostics-path /Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/Objects-normal/x86_64/OFCMSUtilities.dia -emit-dependencies-path /Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/Objects-normal/x86_64/OFCMSUtilities.d -emit-reference-dependencies-path /Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/Objects-normal/x86_64/OFCMSUtilities.swiftdeps -o /Users/bungi/Library/Developer/Xcode/DerivedData/OmniFrameworks-clmbsobdariadbbxdevhpaygpysk/Build/Intermediates/OmniFoundation.build/Debug/OmniFoundation.build/Objects-normal/x86_64/OFCMSUtilities.o 
1.	While running pass #&#8203;884 SILModuleTransform "Mandatory Inlining".
2.	While deserializing decl #&#8203;502 (XREF)in 'Foundation'
3.	Cross-reference to module 'Foundation'
	... NSMutableData
	... length
	... with type Int
4.	If you're seeing a crash here, check that your SDK and dependencies match the versions used to build 'Foundation'
@belkadan
Copy link
Contributor

@belkadan belkadan commented Feb 22, 2017

@swift-ci create

@belkadan
Copy link
Contributor

@belkadan belkadan commented Feb 22, 2017

This seems to be fixed on master, but now we have to figure out what fixed it.

@belkadan
Copy link
Contributor

@belkadan belkadan commented Feb 22, 2017

Hm, unfortunately the fix seems to be the reworking of Foundation.Data to use itself as its own SubSequence type, something too big to cherry-pick into Swift 3.1. There's an actual bug here that we'd need to fix instead.

@belkadan
Copy link
Contributor

@belkadan belkadan commented Feb 23, 2017

It looks like the presence of the -setLength: method in OFByteAcceptor is throwing off the import of the readwrite length property. This is backwards, of course; we shouldn't mirror in any protocol members until after the regular members have been imported.

@belkadan
Copy link
Contributor

@belkadan belkadan commented Feb 23, 2017

Lousy workaround: declare @property NSUInteger length in OFByteAcceptor instead of -setLength:, even though the protocol doesn't technically need it.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants