Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starscream version 0.9.3 crashes on iPhone 5 and under #77

Closed
ghost opened this issue May 5, 2015 · 15 comments
Closed

Starscream version 0.9.3 crashes on iPhone 5 and under #77

ghost opened this issue May 5, 2015 · 15 comments

Comments

@ghost
Copy link

ghost commented May 5, 2015

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Subtype: EXC_ARM_DA_ALIGN at 0x15b58c0a
Triggered by Thread:  2
Thread 2 name:  Dispatch queue: com.apple.root.default-qos
Thread 2 Crashed:
0   Starscream                      0x004c9490 function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Owned To Guaranteed> of Starscream.WebSocket.(processRawMessage in _E91840E7069A0D2D302D042308E9D928) (Starscream.WebSocket)(Swift.UnsafePointer<Swift.UInt8>, bufferLen : Swift.Int) -> () (WebSocket.swift:493)
1   Starscream                      0x004c6d1c function signature specialization <Arg[0] = Owned To Guaranteed> of Starscream.WebSocket.(processInputStream in _E91840E7069A0D2D302D042308E9D928) (Starscream.WebSocket)() -> () (WebSocket.swift:338)
2   Starscream                      0x004c44b4 @objc Starscream.WebSocket.stream (Starscream.WebSocket)(ObjectiveC.NSStream, handleEvent : C.NSStreamEvent) -> () (WebSocket.swift:264)
3   CoreFoundation                  0x252de6d4 _signalEventSync + 144

Version 0.9.1 used to work with the exact use case.
Possibly related to the change from using 'byteSwapped' to using 'bigEndian' on UInt64.

Can I help further?

@ghost
Copy link
Author

ghost commented May 5, 2015

Further inspection reveals this happens consistently on large packets (e.g. 190k~ characters). We haven't witnessed any issue on small packets.

@daltoniam
Copy link
Owner

This sounds like #52. I tested on an iPad 2 with the largest messages possible and it worked properly. What kind of server are you using?

@ghost
Copy link
Author

ghost commented May 6, 2015

We use Jetty for the WebSocket server. The issue doesn't happen on all devices, we verified it on the iPod 5 and iPhone 4S/5.
I've looked into it more today. The crash happens only in release configuration, and not in debug configuration. After playing around some, it seems that setting
SWIFT_OPTIMIZATION_LEVEL = "-Onone"
for XCBuildConfiguration section under the Starscream.xcodeproj/project.pbxproj file relieves the issue.

@daltoniam
Copy link
Owner

Interesting. Not sure what would be specific to those devices to cause an issue. I wonder if it is a bug in the Swift compiler. I don't have those devices to test with, but I will try and see if I can reproduce it change the build flags.

@ghost
Copy link
Author

ghost commented May 7, 2015

First of all what I suggested in the first comment Possibly related to the change from using 'byteSwapped' to using 'bigEndian' on UInt64. doesn't seem right. When I had split the two statements in that line bytes[0] caused the error (rather than bigEndian).

We had two devices with the same iOS version (I believe 8.1.2) - one failing one not.
I hadn't verified that, but a candidate for the scenario in which the optimizations fail might be a 32bit architecture.

@daltoniam
Copy link
Owner

Agreed. The bigEndian vs byteSwapped was just a guess. I agree it isn't what causing the issue. The optimizations on 32bit architecture seems like the best path to explore at this point.

@szuniverse
Copy link

Hi Guys!
Did you find any solution?

@ghost
Copy link
Author

ghost commented May 25, 2015

@szuniverse I'm not aware of any fix to the issue. However, as I've outlined above, I've worked around the issue by disabling Swift code optimization for the Starscream framework.

@daltoniam
Copy link
Owner

I haven't had any time to look into this. I have gotten a couple of reports with different parameters (works on these devices but not this one), but haven't gotten anything solid to test with yet. It is difficult to reproduce as it requires the same environment and devices as the report. Hopefully will come to an answer something soon, but as @asafhlp said, disabling code optimization is the best bet in the mean time.

@szuniverse
Copy link

Thanks. If I set set the SWIFT_OPTIMIZATION_LEVEL = "-Onone" everything works fine for me

@daltoniam
Copy link
Owner

The latest code in master might have resolved this. I had some protection that might help with these random crash issues.

@daltoniam
Copy link
Owner

now that Swift 2 is out, might be worth a test to see if the SWIFT_OPTIMIZATION_LEVEL can be set back to normal.

@Kalluraya
Copy link

Any fix for this issue. This issue still happens on iPhone 5 and iPhone 5C

@daltoniam
Copy link
Owner

@Kalluraya No, changing the SWIFT_OPTIMIZATION_LEVEL still seems to be the answer for 32 bit devices.

@daltoniam
Copy link
Owner

The 1.1.0 release should resolve this. Let us know if you have any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants