You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Segmentation faults when using SwiftyJSON as a subproject #67
changed the title [-]Segmentation faults when using SwiftyJSON as a subpri[/-][+]Segmentation faults when using SwiftyJSON as a subproject[/+]on Oct 9, 2014
I'm seeing this as well. I have two models in two separate files that are referencing the JSON type. If I try to add a third model class in a third file, I run into this compiler crash. But if I lump that third class into one of those first two files, everything's fine.
When we comment out that part, the segmentation fault does not happen.
Including SwiftJSON directly as swift file also seems to solve the problem. I also think its likely a Xcode bug, and we have filed a bugreport to apple
I'm experiencing this even when just importing the swift file
1. While emitting IR SIL function @_TFFC7App20MUpdateOperation17processCachedDataFS0_FT_T_U_FT_T_ for expression at [/Users/mwaterfall/Projects/.../UpdateOperation.swift:420:25 - line:469:9] RangeText=...
Now I have exactly the same issue, but as long as I use SwiftyJSON in file called Server.swift everything works fine. Even if I add another class in that file (doesn't matter if its pure Swift class or class that is subclass for NSObject) it still works. Did any file apple bug report (for my this is bug with compiler)?
I have a segfault 11 too when I just include SwiftyJSON.swift in my project. It occurred suddenly after a small refactoring. Before everything was finde. So I think it has nothing to do with the subproject but with some strange swift compiler behaviour.
Same issue here. I'm having a new surprise at each attempt to compile this.
When registering an Alamofire request callback, that's the compiler error I was receiving:
Command failed due to signal: Segmentation fault: 11
After tried what @yuhua-chen suggested, the problem changed, in a very surprising way:
Undefined symbols for architecture x86_64:
"__TMdV10SwiftyJSON4JSON", referenced from:
__TFFC7example14ViewController11viewDidLoadFS0_FT_T_U0_FV10SwiftyJSON4JSONT_ in ViewController.o
ld: symbol(s) not found for architecture x86_64
After removing the Alamofire callback, the program do compile, which doesn't help.
@endel: would you be able to share a gist of your crashing/non-crashing code? That sounds like a different segfault that I'd like to minimise and report against swiftc asap. Thanks.
Excellent, thanks for putting in the effort with the different cases. Swift compiler crashes are collecting over at practicalswift/swift-compiler-crashes so these reports are golden.
Same here :-(
If you remove "options" parameter from init() and pass "AllowFragments" as default value to NSJSONSerialization (cannot be modified as removed as input parameter)... It works.
It's a shame that Apple had relased this faulty compiler (this is one of the many bugs it has)
I just had this issue! It was hard to track down but essentially once I removed a function that included JSON object from SwiftyJSON class, it crashed my code with the segmentation fault.
So basically if I removed code from the project it crashed.
When I imported SwiftyJSON.swift into my project it started to work.
We got feedback from apple, they request to test it with Xcode 6.3 and the news swift 1.2 compiler. We still have to migrate our project, so we can't yet test it, so if someone else that has the problem could try it with Xcode 6.3 that would be great
@broglep-koubachi I had the exact same pb combining Alamofire and SwiftyJSON doing something like this
Alamofire.request(.GET, APIClientConstants.kApiBaseUrl + "/vls/v1/stations", parameters: params).responseJSON { (req, response, json, error) in
if (error != nil) {
completionHandler(APIResponseState.Error(error!))
}
else {
var json = JSON(json!)
completionHandler(APIResponseState.Correct(json))
}
}
It wouldn't compile under Xcode 6.1.1 and swift 1.1 but it works with swift 1.2 and Xcode 6.3 after manually updating Alamofire and SwiftyJSON to Swift 1.2 of course
Activity
[-]Segmentation faults when using SwiftyJSON as a subpri[/-][+]Segmentation faults when using SwiftyJSON as a subproject[/+]drhr commentedon Oct 13, 2014
I'm seeing this as well. I have two models in two separate files that are referencing the
JSONtype. If I try to add a third model class in a third file, I run into this compiler crash. But if I lump that third class into one of those first two files, everything's fine.drhr commentedon Oct 13, 2014
Now when I try this on a brand new project, any reference to
JSONcauses the seg fault (in 6.0.1 and 6.1 beta 1 and beta 2).Noobish1 commentedon Oct 13, 2014
I'd suggest just importing SwiftyJSON.swift for now, that seemed work fine for me.
drhr commentedon Oct 13, 2014
That works for now 🍺
LukeTangPL commentedon Oct 13, 2014
I think it's a Xcode's bug.
How about this:
broglep-work commentedon Oct 24, 2014
I think we experience the same or a similar problem, we have include the Xcode project as dependency.
With Xcode Version 6.1 (6A1052d) the compilation fails with
Segmentation Fault: 11[snip]
We could track it down to the SwiftJSON init method at https://github.com/SwiftyJSON/SwiftyJSON/blob/master/Source/SwiftyJSON.swift#L67-73
When we comment out that part, the segmentation fault does not happen.
Including SwiftJSON directly as swift file also seems to solve the problem. I also think its likely a Xcode bug, and we have filed a bugreport to apple
jeeftor commentedon Oct 28, 2014
I think i'm having similar issues
edwellbrook commentedon Nov 4, 2014
I'm seeing this issue as well :(
mwaterfall commentedon Nov 5, 2014
I'm experiencing this even when just importing the swift file
Any fixes about?
lhammond commentedon Nov 5, 2014
I am also having this issue
adamszeptycki commentedon Nov 8, 2014
Now I have exactly the same issue, but as long as I use SwiftyJSON in file called Server.swift everything works fine. Even if I add another class in that file (doesn't matter if its pure Swift class or class that is subclass for NSObject) it still works. Did any file apple bug report (for my this is bug with compiler)?
mwaterfall commentedon Nov 17, 2014
Ahh, this is frustrating! Totally unusable, even on Xcode 6.1.1 GM.
dave-kong commentedon Nov 21, 2014
Same issue here. @broglep-koubachi 's suggestion is right on.
16 remaining items
Blackjacx commentedon Jan 17, 2015
I have a segfault 11 too when I just include SwiftyJSON.swift in my project. It occurred suddenly after a small refactoring. Before everything was finde. So I think it has nothing to do with the subproject but with some strange swift compiler behaviour.
endel commentedon Jan 18, 2015
Same issue here. I'm having a new surprise at each attempt to compile this.
When registering an Alamofire request callback, that's the compiler error I was receiving:
After tried what @yuhua-chen suggested, the problem changed, in a very surprising way:
After removing the Alamofire callback, the program do compile, which doesn't help.
rustedivan commentedon Jan 18, 2015
@endel: would you be able to share a gist of your crashing/non-crashing code? That sounds like a different segfault that I'd like to minimise and report against swiftc asap. Thanks.
endel commentedon Jan 18, 2015
@rustedivan sure, here it is: https://gist.github.com/endel/6e2f9ac7279a6ee42b90
I've written 3 examples to demonstrate what is happening for me:
I'm using a custom Request class for this.
rustedivan commentedon Jan 18, 2015
Excellent, thanks for putting in the effort with the different cases. Swift compiler crashes are collecting over at practicalswift/swift-compiler-crashes so these reports are golden.
Blackjacx commentedon Jan 19, 2015
For me the following caused a segfault while
typeis an optional:and this solved it:
sman591 commentedon Feb 7, 2015
@kostiakoval's workaround solved it for me. I pushed a copy of the changes to https://github.com/sman591/SwiftyJSON/tree/compiler-segfault-workaround in case anyone else wants to try it.
jzarzuel commentedon Feb 15, 2015
Same here :-(
If you remove "options" parameter from init() and pass "AllowFragments" as default value to NSJSONSerialization (cannot be modified as removed as input parameter)... It works.
It's a shame that Apple had relased this faulty compiler (this is one of the many bugs it has)
sferoze commentedon Feb 20, 2015
I just had this issue! It was hard to track down but essentially once I removed a function that included JSON object from SwiftyJSON class, it crashed my code with the segmentation fault.
So basically if I removed code from the project it crashed.
When I imported SwiftyJSON.swift into my project it started to work.
Here was the stack overflow I posted: http://stackoverflow.com/questions/28623405/why-can-i-not-remove-an-unused-function-from-my-swift-class
broglep-work commentedon Feb 20, 2015
We got feedback from apple, they request to test it with Xcode 6.3 and the news swift 1.2 compiler. We still have to migrate our project, so we can't yet test it, so if someone else that has the problem could try it with Xcode 6.3 that would be great
imanzarrabian commentedon Feb 20, 2015
@broglep-koubachi I had the exact same pb combining Alamofire and SwiftyJSON doing something like this
It wouldn't compile under Xcode 6.1.1 and swift 1.1 but it works with swift 1.2 and Xcode 6.3 after manually updating Alamofire and SwiftyJSON to Swift 1.2 of course
Quick and dirty fix for the Segmentation fault
thekie commentedon Mar 22, 2015
+1 Removing the options parameter from init(data:options:error:) worked for me as well.
Isuru-Nanayakkara commentedon Apr 18, 2015
This seems to be fixed in Xcode 6.3.