Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 288 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Swift compiler segmentation fault when building

#31
Like **@Fjohn** said, this was an issue related to unwrapping an optional for me (broke in both Xcode 7.0 beta 6 and Xcode 7). In my case, I was not unwrapping optional of the optional (what tipped me off was double ?? in the descriptor. Using ***if let*** solved the issue

[![double optional causing segmentation fault][1]][1]


[1]:
Reply

#32
Seems like the Swift 2 compiler might not have been quite ready for prime-time! In case this helps anyone, I was getting a segmentation fault: 11 due to a mismatch with the variable type in a closure header, specifically in a Parse method, `PFQuery.query.findObjectsInBackgroundWithBlock`.

You can see the issue in more detail here:
[

[To see links please register here]

][1]


[1]:

[To see links please register here]

Reply

#33
I had this error too, and I fixed it like this:

Check your project and find out which files are used twice and remove one, or delete and re-add them all.

Errors in my Xcode:

> <unknown>:0: error: filename "AttributedString.swift" used twice:
> '/Users/.../CNJOB/CNJOB/AttributedString.swift' and
> '/Users/.../CNJOB/CNJOB/AttributedString.swift'
>
> <unknown>:0: note: filenames are used to distinguish private
> declarations with the same name
>
> <unknown>:0: error: filename "APIClient.swift" used twice:
> '/Users/.../CNJOB/CNJOB/APIClient.swift' and
> '/Users/.../CNJOB/CNJOB/APIClient.swift'
>
> <unknown>:0: note: filenames are used to distinguish private
> declarations with the same name
>
> Command /Applications/Xcode
> 3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc
> failed with exit code 1
Reply

#34
I'll throw the reason I was getting this crash in the ring since so many different issues seem to be causing variations of this compiler issue.

My "while emitting SIL" was referencing an 'observeValueForKeyPath' method and I couldn't for the life of me figure out what was wrong with it (it worked fine in swift 1.2). The issue, oddly, ended up being with parenthesis around my case statements.

This worked before Swift 2.0...

switch (context) {
case(&myContext):
print("observed")
}

This stopped the compiler error...

switch (context) {
case &myContext:
print("observed")
}

Hope this answer helps a couple of people save a little time.
Reply

#35
The problem for me was:

var startIndex : Int = etc...

Then I had:

startIndex++

Commenting out the ```startIndex++``` prevented the error, so the fix was to use ```startIndex : Double``` and casting its comparison and such to ```Double```
Reply

#36
In Xcode 7, you can click on the error in the Debug Navigator and you'll be shown an expanded view of the crashes. Clicking on the hamburger button on the right expands the error, and if you scroll all the way down to the bottom of the expanded error message, you will see where it comes from.

![enter image description here][1]

For me, I had two of those segmentation fault errors. In the picture above, the first one is what it looks like when collapsed, the second is when you expand the hamburger button. At the very bottom of the expanded gray box, you'll see a message that says where the compiler crashed.

Note however that the error message may at times be not informative enough, so while it tells you where it crashed, it doesn't always say why and how to fix it. Getting rid of this error is still very much a matter of guesswork.

[1]:
Reply

#37
Im my case, this happened when I did incorrect static initialization in a protocol. I found a way to get around, but a compiler should *never* produce a segmentation fault while building.

There are three files involved. A protocol NamedSegues.swift, a custom TableViewController that among other things implements the protocol which contains a callback, a custom TableViewCell that holds reference to this protocol to call the callback.


//file1
import Foundation
protocol NamedSegues {
func executeSegueWithId(id: String) -> Void
static func getDefault() -> NamedSegues // This was required because of init requirement in CustomCellView
}


//file2
class CustomController: UITableViewController, NamedSegues {
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("CustomCellID", forIndexPath: indexPath ) as! CustomCellView

// Configure the cell...
//App logic...

cell.parent = self
}

//Mark: NamedSegues
func executeSegueWithId(id: String) ->() {
NSLog("Received callback to execute segue: \(id)")
//
}

static func getDefault() -> NamedSegues { // I think this must be where it threw up.
return self as! NamedSegues
}

}


//file3

import UIKit

class CustomCellView: UITableViewCell {

var id: String = "NoName"
var parent: NamedSegues = NamedSegues.getDefault() // This is where it was needed.


override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
NSLog("Touched id: \(id)")


parent.executeSegueWithId(id) // This is where parent was used.
}
}

I got around it by using ?

In the protocol file, file1: delete the declaration of getDefault()
In the CustomController file2: delete the implementation of getDefault.
In the CustomCellView, file3:


var parent: NamedSegues?
...
parent?.executeSegueWithId(id)

The compiler should have caught this and given some error message instead of throwing a segmentation fault during build!
Reply

#38
Discovered yet another way to get this error while attempting to use an empty struct with [Argo](

[To see links please register here]

):

*Causes Segmentation Fault 11:*

struct Action {
// let foo: String
}

extension Action: Decodable {
static func decode(json: JSON) -> Decoded<Action> {
return .MissingKey("foo")
}
}

*Compiles just fine:*

struct Action {
let foo: String
}

extension Action: Decodable {
static func decode(json: JSON) -> Decoded<Action> {
return .MissingKey("foo")
}
}

Sigh.
Reply

#39
It looks like it can be caused by a lot of reasons lol. In my case it was the pch file - when I tried to import the .pch file in `bridging-header.h` I got the segmentation fault and I assume maybe it's caused by the `PROJECT-swift.h` inside. So what I should do is putting everything swift needs into another const.h and `#import "const.h"` in both .pch and `bridgng-header.h`. This is a pretty dumb mistake I made but hope it can help some random guys come cross.
Reply

#40
I had the same problem in a swift project. The issue was a function that should have returned an object, but didn't have a return in it. This sort of error used to be signaled while editing with Obj-C. It seems like t isn't the case in Swift.
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through