Abort trap: 6

I'm getting an Abort Trap: 6 after bringing in over a project from XCode 6.3. Here's what I'm getting in 7.0:


CompileSwift normal x86_64 /Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffViewElementLayer.swift
    cd /Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c "/Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffViewElement.swift" "/Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffView.swift" "/Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/NotePickerViewController.swift" "/Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/FingeringViewController.swift" -primary-file "/Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffViewElementLayer.swift" "/Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffViewNote.swift" "/Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/DeveloperTableViewController.swift" "/Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffViewKeySignature.swift" "/Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffViewStaffLayer.swift" "/Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/AppDelegate.swift" -target x86_64-apple-ios8.0 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk -I /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Products/Debug-iphonesimulator -F /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/mike/Library/Developer/Xcode/DerivedData/ModuleCache -serialize-debugging-options -Xcc -I/Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/BSNFingerings-generated-files.hmap -Xcc -I/Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/BSNFingerings-own-target-headers.hmap -Xcc -I/Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/BSNFingerings-all-target-headers.hmap -Xcc -iquote -Xcc /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/BSNFingerings-project-headers.hmap -Xcc -I/Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/DerivedSources/x86_64 -Xcc -I/Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0 -emit-module-doc-path /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/Objects-normal/x86_64/MusicStaffViewElementLayer~partial.swiftdoc -Onone -module-name BSNFingerings -emit-module-path /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/Objects-normal/x86_64/MusicStaffViewElementLayer~partial.swiftmodule -serialize-diagnostics-path /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/Objects-normal/x86_64/MusicStaffViewElementLayer.dia -emit-dependencies-path /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/Objects-normal/x86_64/MusicStaffViewElementLayer.d -emit-reference-dependencies-path /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/Objects-normal/x86_64/MusicStaffViewElementLayer.swiftdeps -o /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/Objects-normal/x86_64/MusicStaffViewElementLayer.o
Assertion failed: (gen.getTypeLowering(result.getType()).isTrivial() && "nontrivial result is returned unowned?!"), function emitObjCReturnValue, file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.38.1/src/swift/lib/SILGen/SILGenBridging.cpp, line 649.
0  swift                    0x000000010aaa7e0b llvm::sys::PrintStackTrace(__sFILE*) + 43
1  swift                    0x000000010aaa854b SignalHandler(int) + 379
2  libsystem_platform.dylib 0x00007fff97cf9f1a _sigtramp + 26
3  libsystem_platform.dylib 0x00007feb8a991a10 _sigtramp + 4073290512
4  libsystem_c.dylib        0x00007fff8fb29b53 abort + 129
5  libsystem_c.dylib        0x00007fff8faf1c39 basename + 0
6  swift                    0x0000000108cd9e8a swift::Lowering::SILGenFunction::emitNativeToForeignThunk(swift::SILDeclRef) + 7722
7  swift                    0x0000000108cb67af swift::Lowering::SILGenModule::emitObjCPropertyMethodThunks(swift::AbstractStorageDecl*) + 335
8  swift                    0x0000000108d4f1da (anonymous namespace)::SILGenType::emitType() + 602
9  swift                    0x0000000108d4eede swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 30
10 swift                    0x0000000108cb728b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 571
11 swift                    0x0000000108cb806f swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 703
12 swift                    0x0000000108cb828b swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 123
13 swift                    0x0000000108ac1691 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 9153
14 swift                    0x0000000108abf0b3 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2515
15 swift                    0x0000000108abb28f main + 1983
16 libdyld.dylib            0x00007fff980285c9 start + 1
17 libdyld.dylib            0x0000000000000043 start + 1744665211
Stack dump:
0. Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffViewElement.swift /Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffView.swift /Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/NotePickerViewController.swift /Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/FingeringViewController.swift -primary-file /Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffViewElementLayer.swift /Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffViewNote.swift /Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/DeveloperTableViewController.swift /Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffViewKeySignature.swift /Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffViewStaffLayer.swift /Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/AppDelegate.swift -target x86_64-apple-ios8.0 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk -I /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Products/Debug-iphonesimulator -F /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/mike/Library/Developer/Xcode/DerivedData/ModuleCache -serialize-debugging-options -Xcc -I/Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/BSNFingerings-generated-files.hmap -Xcc -I/Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/BSNFingerings-own-target-headers.hmap -Xcc -I/Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/BSNFingerings-all-target-headers.hmap -Xcc -iquote -Xcc /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/BSNFingerings-project-headers.hmap -Xcc -I/Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/DerivedSources/x86_64 -Xcc -I/Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0 -emit-module-doc-path /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/Objects-normal/x86_64/MusicStaffViewElementLayer~partial.swiftdoc -Onone -module-name BSNFingerings -emit-module-path /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/Objects-normal/x86_64/MusicStaffViewElementLayer~partial.swiftmodule -serialize-diagnostics-path /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/Objects-normal/x86_64/MusicStaffViewElementLayer.dia -emit-dependencies-path /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/Objects-normal/x86_64/MusicStaffViewElementLayer.d -emit-reference-dependencies-path /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/Objects-normal/x86_64/MusicStaffViewElementLayer.swiftdeps -o /Users/mike/Library/Developer/Xcode/DerivedData/BSNFingerings-hiiapxyakgjrapgckzxtjwitnpsw/Build/Intermediates/BSNFingerings.build/Debug-iphonesimulator/BSNFingerings.build/Objects-normal/x86_64/MusicStaffViewElementLayer.o
1. While silgen objc property getter thunk SIL function @_TToFC13BSNFingerings26MusicStaffViewElementLayerg4pathGSQCSo6CGPath_ for 'path' at /Users/mike/Cocoa/BitBucket/bassoon-fingerings-3.0/Bassoon Fingerings/MusicStaffView/MusicStaffViewElementLayer.swift:89:18


Where do I go from here? Optimization settings don't seem to change anything. Reinstalling XCode doesn't help anything. Don't know what to do now.

The offending code is in this file and is commented out in this version (lines 25-34):


class MusicStaffViewStaffLayer: CAShapeLayer {
  
    var maxLedgerLines : Int = 0
    var currentHorizontalPosition : CGFloat {
        get {
            if let sublayers = self.sublayers! as? [CALayer] {
                if let lastElement = sublayers.last as CALayer! {
                    return lastElement.frame.origin.x + lastElement.frame.size.width
                }
            }
            return 0
        }
    }
  
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        strokeColor = UIColor.blackColor().CGColor
    }
  
    override init() {
        super.init()
        strokeColor = UIColor.blackColor().CGColor
    }
  
/*
   override var path : CGPath? {
        get {
            return staffPath()
        }
        set {
           
        }
    }
*/
  
    func staffPath() -> CGPathRef {
        let staffLines = UIBezierPath()
        let spaceWidth : CGFloat = self.bounds.size.height / (6.0 + 2.0 * CGFloat(maxLedgerLines))
        self.lineWidth = spaceWidth / 10.0
      
        for i in 1...(5 + maxLedgerLines) {
            if (i <= maxLedgerLines || i > 5 + maxLedgerLines) {
                continue
            }
          
            let height = self.bounds.origin.y + spaceWidth * CGFloat(i)
            staffLines.moveToPoint(CGPointMake(self.bounds.origin.x, height))
            staffLines.addLineToPoint(CGPointMake(self.bounds.origin.x + self.bounds.size.width, height))
        }
      
        return staffLines.CGPath
    }

}

Maybe the reason the compiler is crashing because your code is trying to override a stored property in obj-c with a computed property in Swift?


I would recommend filing a bug with your example code above, since the compiler/sourcekit shouldn't be crashing like that, and should provide an error if there is a problem with the code.


Is there a reason why you can't leave out the override of path: and just set it in init like you do with strokeColor?


required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        strokeColor = UIColor.blackColor().CGColor
        path = staffPath()
    }

    override init() {
        super.init()
        strokeColor = UIColor.blackColor().CGColor
        path = staffPath()
    }

I have the same problem (6.3 project -> 7.0 beta-1, "abort trap: 6"). I briefly got the error to go away and my project to build and run by changing a build setting for the static analyzer, but it was only tmporary, the error is back and my project is dead in the water until I figure out how to fix it.


I have tried commenting out the line that is supposedly causing the problem, but the error just jumps somewhere else, so I think the problem is more complex than just something in a specific line of code.

Does your code also have Swift subclasses of an obj-c parent class?


Just wondering what your project might have in common with mmuszynski's project, to try to narrow down the problem...

@LCS, yes, I do have many subclasses of Objective-C classes. But it's a SceneKit app where just about every object, including my custom classes, are derived from a SceneKit Objective-C object, like SCNNode (which inherits from NSObject), so it's pretty much impossible for me to test by removing those objects.


I did try removing all overrides of Objective-C computed properties ("override var ...") as suggested above, but it did not help.


I also have quite a few extensions and some global utility functions, many of which extend or operate on Obj-C objects or structs. But again, removing those would totally break my app and generate a thousand errors (before "Abort trap: 6" gets hit), so I can't test it.

I'm continuing to test this and have found something interesting. At least in my case, the problem appears to have something to do with SceneKit's SCNVector3 type. Here's what I did.


1. Create a brand-new project in Xcode 7 beta-1. Type is "Game", Language is "Swift", Game Technology is "SceneKit".


2. Build and run with default settings. Project builds and runs fine in simulator (you will see the default rotating 3D spaceship model).


3. Add a single SCNVector3 property to the gamecontroller in GameViewController.swift, like this:


class GameViewController: UIViewController {
  var p = SCNVector3Zero


Lo and behold, guess who pops up? Our friend "Abort trap: 6". Project will no longer compile.


4. Change the constant to an empty initializer.


class GameViewController: UIViewController {
  var p = SCNVector3()


Same problem, "Abort trap: 6"


5. Remove property, restoring to the clean project state. "Abort trap: 6" is gone, project again compiles and runs.


6. Try adding SCNVector4 instead of SCNVector3.


class GameViewController: UIViewController {
  var p = SCNVector4Zero


Project still compiles and runs.


Hmm. So it seems there's something specifically horked with SceneKit's SCNVector3 type. Which is a show-stopper because if you have a SceneKit project, you'll be using that type all over the place. Maybe there's a way to re-create /override/extend SCNVector3 to bypass this temporarily? Don't know yet. This is what seems to be problematic in my particular project. However, there may be similar problems with other types in other projects that may also cause "Abort trap: 6". Possibly something in the hierarchy that multiple types are using.

Just to make sure, I followed the same steps as above except I made the project Objective-C instead of Swift. Objective-C version has no problem with adding a SCNVector3 property, so I think the problem is specific to Swift. And because of that, this issue might get more attention in the (more active) Swift forum. If no one has yet referenced "Abort trap: 6" there, I'm going to start a thread there that references this one.

It's also specific to the iOS version of the Game template. The OS X version of the Game template doesn't have the same problem when using Swift.

As I posted in the other thread, I think the Abort Trap: 6 error during compile is the result of failed assertions in the Swift compiler. and different bugs could be causing different assertions to fail but generate the same overall error.


They may have the same underlying cause, but your SCNVector3 issue is triggering this assertion:

Assertion failed: ((IGF.IGM.DataLayout.getTypeSizeInBits(coercionTy) == IGF.IGM.DataLayout.getTypeSizeInBits(paramTI.StorageType)) && "Coerced types should not differ in size!"), function emitDirectExternalParameter, file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.38.1/src/swift/lib/IRGen/IRGenSIL.cpp, line 908.


and mmuszynski's code is triggering this one:

Assertion failed: (gen.getTypeLowering(result.getType()).isTrivial() && "nontrivial result is returned unowned?!"), function emitObjCReturnValue, file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.38.1/src/swift/lib/SILGen/SILGenBridging.cpp, line 649.


I think your example with the default iOS Game template should be enough for Apple's engineers to figure out what the source of your problem is, and you could go ahead and file a bug report with that info.

Ah, interesting. Well it seems like it's a broad enough problem that it will probably get fixed soon, but you never know. I encourage people to file bug reports anyway (I did, copied in the Swift forum thread).

Abort trap: 6
 
 
Q