Gieta Laksmana
  • Blog
  • Profile
  • Projects
    • VR World Arcade
    • Punch For Fun
    • Spectrum
    • Dimension Battle
  • Resume

Xcode 8 Swift 3 compiler bug segmentation fault 11

9/21/2016

0 Comments

 
Recently I've had to go through the hellish task of upgrading my Swift 2 projects to Swift 3. tldr, 1000+ errors fixed later, I was left with 1 persistent error. command failed due to signal: Segmentation fault: 11

​I've never seen this compiler error before, and preliminary research suggested that it's a possible bug in the swift compiler itself.

Thankfully it tells me which file did the fault happened:
While type-checking declaration 0x7fc447c12e00 at /Users/gietal/dev/project/source/Extensions/FileManager+Extensions.swift:5:8
​
It doesn't tell me where in the file did it breaks, but at least I had a starting point. Luckily this file of mine is not that huge, so I'm able to brute force isolate each functions in the file and found that the culprit is a very specific function declaration.

This form of function declaration is the one that's causing the segmentation fault:
public extension FileManager {
  public func foo() throws -> URLRelationship {
    return URLRelationship.other
  }
}
I've found that omitting the throws keyword will avoid this error:
public extension FileManager {
  public func foo() -> URLRelationship {
    return URLRelationship.other
  }
}
This is a very weird behaviour, since if I mark the function with the throws keyword and have it return anything else EXCEPT URLRelationship it will compile just fine. This only happens if the function is marked throws and returns a URLRelationship.

I've filed a bug to Apple regarding this, as I've found someone else had had a similar issue like this with Swift 2.2 before:
​http://blog.bellebethcooper.com/xcode-bug.html

Anyway, this has been an annoying one to track. For now I will just have to workaround the issue by omitting the throws keyword and handle error thrown inside the function some other way.

I hope this post can help someone else who ran into the same issue. If this doesn't help, at least I hope this can give you some ideas into where to start isolating your code to find the offending piece of code.
0 Comments



Leave a Reply.

    Archives

    September 2018
    August 2018
    July 2018
    September 2017
    July 2017
    November 2016
    October 2016
    September 2016
    June 2016
    May 2016
    March 2016

    Categories

    All
    Shenanigans
    Software Engineering
    Swift
    Vr
    Xcode

    RSS Feed

Powered by Create your own unique website with customizable templates.