Starscream icon indicating copy to clipboard operation
Starscream copied to clipboard

I got crashes on iOS SDK 4.0.4, Starscream.TCPTransport.connect

Open lilyDong opened this issue 1 year ago • 4 comments

Describe the bug

Starscream.TCPTransport.connect(url: Foundation.URL, timeout: Swift.Double, certificatePinning: Starscream.CertificatePinning?, domain: Swift.String) -> ()

Steps to Reproduce

have no idea, just got crashes on our platform

Expected behavior

No crash

Environment:

  • OS/Version: [iOS/16.6 16.5.1 16.6.1 16.7.1]
  • Starscream Version [4.0.4]
  • Xcode version [14.2]

logs: image

BACKGROUND THREAD 42 - CRASHED libswiftCore.dylib _swift_release_dealloc libswiftCore.dylib bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) libswiftNetwork.dylib Network.NWConnection.deinit libswiftNetwork.dylib Network.NWConnection.__deallocating_deinit libswiftCore.dylib _swift_release_dealloc libswiftCore.dylib bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) OKApp Starscream.TCPTransport.connect(url: Foundation.URL, timeout: Swift.Double, certificatePinning: Starscream.CertificatePinning?, domain: Swift.String) -> () <compiler-generated>:0 OKApp Starscream.WSEngine.start(request: Foundation.URLRequest) -> () WSEngine.swift:67 OKApp protocol witness for Starscream.Engine.start(request: Foundation.URLRequest) -> () in conformance Starscream.WSEngine : Starscream.Engine in Starscream <compiler-generated>:0

lilyDong avatar Oct 31 '23 10:10 lilyDong

I can reproduce this crash as well. It happens 100% of the time for my app when run on iOS 16 devices. Interestingly this crash does not happen in the last version of my app that I released, and I did not update Starscream between then and now. So the issue must be tied to a specific way that I'm now using this library, or maybe I've introduced a memory issue that happens to always manifest in Starscream code.

Describe the bug

I launch my app on an iOS 16 device, and it crashes. 100% reproducible, even if I delete and reinstall the app.

Expected behavior

No crash

Environment:

OS/Version: iPhone 14 Pro iOS 16.0.2, iPhone SE (2nd gen) iOS 16.2, iPhone 14 Pro Simulator iOS 16 Starscream Version: 4.0.4 Xcode version: 15

Crash log:

Incident Identifier: CB6FC8F5-A9E1-4F94-B647-BC31F213A3D4 Beta Identifier: 2B6B8DD0-A559-44FD-BA71-5B0AE11657A3 Hardware Model: iPhone12,8 Version: 3.37.231106 (910) AppStoreTools: 15A240a AppVariant: 1:iPhone12,8:16 Beta: YES Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1]

Date/Time: 2023-11-02 17:07:26.1068 -0700 Launch Time: 2023-11-02 17:07:23.8841 -0700 OS Version: iPhone OS 16.2 (20C65) Release Type: User Baseband Version: 4.00.00 Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000 Exception Codes: 0x0000000000000001, 0x0000000000000000 Termination Reason: SIGNAL 11 Segmentation fault: 11 Terminating Process: exc handler [1467]

Triggered by Thread: 0

Kernel Triage: VM - pmap_enter retried due to resource shortage VM - pmap_enter retried due to resource shortage VM - pmap_enter retried due to resource shortage VM - pmap_enter retried due to resource shortage VM - pmap_enter retried due to resource shortage

Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 ??? 0x0 ??? 1 Starscream 0x106b3e4c8 WSEngine.start(request:) + 632 2 Starscream 0x106b3fefc protocol witness for Engine.start(request:) in conformance WSEngine + 20 3 Starscream 0x106b36fc0 WebSocket.connect() + 216 ... (redacted)

jaltreuter avatar Nov 03 '23 16:11 jaltreuter

Actually it turns out a code update within my project is not the root cause; the crash was introduced because I switched to building with Xcode 15.

When building with Xcode 15 and running on iOS 16 devices, my app always crashes as described above. I rebuilt the same code with Xcode 14.3.1 and ran it on the same iOS 16 device, and there was no crash.

jaltreuter avatar Nov 03 '23 17:11 jaltreuter

This appears to be a duplicate of https://github.com/daltoniam/Starscream/issues/983

jaltreuter avatar Nov 03 '23 17:11 jaltreuter

I updated to Starscream 4.0.6 and compiled the project with a min iOS version of 13.0, and the crash went away.

My understanding is that the default min iOS version for Starscream version 4.0.6 is actually iOS 12, and that that should solve the problem, but I didn't confirm that case specifically.

jaltreuter avatar Nov 03 '23 18:11 jaltreuter