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:
  • 255 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Command failed due to signal: Segmentation fault: 11

#51
For me this was caused by some of my code. The detailed compiler output in XCode actually pin-pointed the method where it was crashing.

I then commented out all the code in the method, made it return nil, and it did compile. I then re-implemented the method using different and much simpler code, and it worked.

I filed a bug report with Apple. This is the - admittedly somewhat crazy - code that caused the crash in XCode 7 / Swift 2.0.

func numberAndTitleFromDirectoryName(dirName: String) -> (Int, String)? {
let components = dirName.characters.split(maxSplit: 1, allowEmptySlices: false) { $0 == " " }.map { String($0) }.map { String($0) }
if let number = components.first?.toInt() {
if let title = components.last {
return (number, title)
}
}
return nil;
}

I guess I got a little over-excited using the map function there... The new version is a lot simpler and also more human comprehensible. Still the compiler shouldn't crash. At worst it should show some errors. The code as is worked in Swift 1.x
Reply

#52
I also had the Segmentation Fault 11, when importing a framework made by myself (yeah, felt really dumb).

After developing the framework for months and integrating it into a main project with intermixed Obj-C and Swift, importing to Obj-C was a no-problem, but as soon as I wrote the `import MySwiftProject` in Swift, all hell broke loose.

Long story short, the problem was that I created some custom methods that provide typification for `NSNotifications` using closures, for example:

<!-- language: swift -->

func post(a : Int, b : String)
{
NSNotificationCenter.defaultCenter().postNotification("notification", object: nil, userInfo: ["a" : a, "b" : b])
}

func observe(block : (a : Int, b : String) -> ()) -> NSObjectProtocol
{
return NSNotificationCenter.defaultCenter().addObserverForName("notification", object: nil, queue: nil)
{
(n : NSNotification!) -> () in

// Unwrap the notification payload and provide types
if let a = n.userInfo?["a"] as? Int, let b = n.userInfo?["b"] as? String
{
block(a, b)
}
}
}

(Actually, the code above I did with a template, but that's another story)

The main culprit? This:

func ... -> NSObjectProtocol

Apparently, Apple can use `NSObjectProtocol` in the declaration of `NSNotification`'s methods, but when I do, it introduces a `Segfault 11`. Replacing `NSObjectProtocol` to `AnyObject` solved the crash.

Unfortunately, this might not solve your issue, since segfault 11 is simply a generic crash of the compiler, but you can take steps to solve it. It took me around 2 hours, but this is what I did:

1. Create a new project, replicating the structure you had. In my case, I created a single view controller swift project, and added a swift framework inside as another project.
2. Copy all the original code from one to another.
3. Go to the compilation phase, and start removing files to compile, try disabling pieces of code that are very swift-hacky (like my NSNotification typification).
4. Every time you do a change, do a clean (<kbd>⌘</kbd><kbd>⌥</kbd><kbd> ⇧ </kbd>+<kbd>K</kbd>), build (<kbd>⌘</kbd>+<kbd>B</kbd>) and fix any errors.
5. Repeat from 3 until the segmentation fault goes away.
Reply

#53
For anyone else coming across this... I found the issue was caused by importing a custom framework, I have no idea how to correct it. But simply removing the import and any code referencing items from the framework fixes the issue.

(╯°□°)╯︵ ┻━┻

Hope this can save someone a few hours chasing down which line is causing the issue.
Reply

#54
I had that code 11 when trying to build for release scheme. It pointed out one viewcontroller class (swift) that had this piece of code inside:

required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
stuff...
}

The problem was that when I have added superclass to it, I forgot to also implement init. So that super.init caused compiler error Segmentation fault: 11
So if you have such problem it's good idea to check also any superclasses.


Reply

#55
I actually screwed up Core Data entities a bit while porting from Swift 2.0 to 1.2 (don't ask why)
I deleted all the entity classes and recreated them again. I got lots of error messages then and when I fixed them all the project built successfully.
Reply

#56
I got rid of this error by following.

I had many frameworks added in "Link Binary With Libraries" and was using a bridging header as well.

I re-added all the frameworks and added the bridging header again. This solved my issue.
Reply

#57
One of case, is that you have named datatype of getter variable like its name.
For example:

var someInstance: someInstance {...


----------
Update #1.
Keep attention on **_a** variable which isn't Int, and you forget to point right return type. Issue happens in more than two operands of infix operator.

function getInt(value: Int) -> Int {
return _a? ?? _b?.count ?? 0
}
Reply

#58
You can get this error when the compiler gets too confused about what's going on in your code. I noticed you have a number of what appear to be functions nested within functions. You might try commenting out some of that at a time to see if the error goes away. That way you can zero in on the problem area. You can't use breakpoints because it's a compile time error, not a run time error.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

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