"Abort trap: 6" error in Swift 2 with Xcode 7 beta-1

Hello, I have gotten this error that prevents my project from compiling, and others have reported it as well in various places. My project is Swift with SceneKit, migrated from 6.3.X to 7, but I have also been able to reproduce it with a fresh project created in Xcode 7 beta-1. If you are having this problem, please see this discussion for details:


https://forums.developer.apple.com/message/10714


I am starting a thread here in the Swift forum because it seems the issue is Swift-specific (and possibly SceneKit-specific as well) and this is a more active forum. If we can some more discussion and testing, we can start submitting bug reports on this, but I would like to gather more information from other users before I do that to narrow down the problem.

Messing around a bit, I think the Abort Trap: 6 error during compile is the result of failed assertions in the Swift compiler.


So different bugs could be causing different assertions to fail, but generating the same overall error.

I filed a bug report based on my own situation. Hopefully more people will submit bug reports and Apple will coalesce them. Here's the info:


Bug ID: 21376523


Title: Adding property of type SCNVector3 yields "Abort trap: 6" error


Classification: Serious Bug


Reproducibility: Always


Description:


When using Swift 2 with Xcode 7 beta-1 (7A120f), with SceneKit, using SCNVector3 produces "Abort trap: 6" compile error. This happens whether a project is migrated from (Swift 1.2 + Xcode 6.3) to (Swift 2 + Xcode 7.0), or with a fresh Swift 2 + Xcode 7.0 project. Error text is below:


------------------


[COMMAND LINE COMPILER OPTIONS OMITTED BECAUSE OF 3,000 WORD BUG REPORT LIMIT]


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.

0 swift 0x000000010c9cae0b llvm::sys::PrintStackTrace(__sFILE*) + 43

1 swift 0x000000010c9cb54b SignalHandler(int) + 379

2 libsystem_platform.dylib 0x00007fff9030cf1a _sigtramp + 26

3 libsystem_platform.dylib 0x0000000000000007 _sigtramp + 1875849479

4 libsystem_c.dylib 0x00007fff900cab53 abort + 129

5 libsystem_c.dylib 0x00007fff90092c39 basename + 0

6 swift 0x000000010ab1269d (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 13693

7 swift 0x000000010ab0ed52 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 498

8 swift 0x000000010aa5f46c swift::irgen::IRGenModuleDispatcher::emitGlobalTopLevel() + 412

9 swift 0x000000010aaf5515 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 821

10 swift 0x000000010aaf5926 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, unsigned int) + 70

11 swift 0x000000010a9e505f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 11663

12 swift 0x000000010a9e20b3 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2515

13 swift 0x000000010a9de28f main + 1983

14 libdyld.dylib 0x00007fff92d4d5c9 start + 1

Stack dump:


[0. PROGRAM ARGUMENTS OMITTED BECAUSE OF 3,000 WORD BUG REPORT LIMIT]


1. While emitting IR SIL function @_TToFC18AbortTrapTestSwift18GameViewControllers1pVSC10SCNVector3 for 'p' at /Users/bstahl/Library/Mobile Documents/com~apple~CloudDocs/Developer/Code/AbortTrapTestSwift/AbortTrapTestSwift/GameViewController.swift:14:6


Steps to reproduce:


Setup: Install Xcode 7.0 (7A120f). Check for current SDKs and documentation in Preferences and install.


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


--> Produces "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. Change "var" to "let".


class GameViewController: UIViewController {

let p = SCNVector4Zero


-- > Compiles and runs.


7. Change property type to SCNVector4 instead of SCNVector3.


class GameViewController: UIViewController {

var p = SCNVector4Zero


-- > Compiles and runs.


Expected results: Project should compile and run. Before adding SCNVector3 property, project already runs, therefore it should already be using SceneKit and its associated type.


Actual results: Project will not compile and exits with "Abort trap: 6" error. There are no suggestions for fixing the problem.


Additional information:


Bug DOES NOT occur if:

- property "var" is changed to "let".

- property type is changed from SCNVector3 type to SCNVector4 type ("var" or "let").

- property declaration is removed from project.

- project is created and compiled under Swift 1.2 in Xcode 6.3.X


Bug STILL occurs if:

- property uses an initializer instead of SCNVector3Zero ("var p = SCNVector3()").

See my thread here: https://forums.developer.apple.com/message/6135#6135


It also involves the use of SCNVector3 (as a mere parameter), leading to the dreaded "Abort trap: 6" error.

Adding a ! like so seems to have worked.


func normalize(vec: SCNVector3!) -> SCNVector3! {

// code

}


very odd

I find the similar error happens when using AVAudio3DPoint. And in my case, it happens only for 64-bit targets.

And you can reproduce it with declaring functions with AVAudio3DPoint param.


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.


Seems to be an alignment problem?

I haven't tested it yet, but it appears they have fixed this in Xcode 7.0 beta-2. Yay! The bug # given is the same they gave me when they closed my bug report as a duplicate.


A compiler crash when calling C or Objective-C functions that take SIMD float3 parameters has been fixed. (21294916)


My code containing AVAudio3DPoint compiles well with beta 2: Version 7.0 beta (7A121l).

"Abort trap: 6" error in Swift 2 with Xcode 7 beta-1
 
 
Q