Uploaded image for project: 'Swift'
  1. Swift
  2. SR-4022

Compiler crash when using inlines from Foundation in another framework

    XMLWordPrintable

    Details

      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 #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'
      ```

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            tjw Timothy Wood
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: