Description
EXC_BAD_ACCESS (SIGBUS)
0 libobjc.A.dylib objc_msgSend + 16
1 xxxxxx -[SRProxyConnect _failWithError:] (SRProxyConnect.m:140)
2 xxxxxx -[SRProxyConnect stream:handleEvent:] (SRProxyConnect.m:0)
3 CoreFoundation _signalEventSync + 212
4 CoreFoundation _cfstream_shared_signalEventSync + 460
5 CoreFoundation CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 24
6 CoreFoundation __CFRunLoopDoSources0 + 276
7 CoreFoundation __CFRunLoopRun + 1204
8 CoreFoundation CFRunLoopRunSpecific + 552
9 Foundation -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 304
10 xxxxxx -[SRRunLoopThread main] (SRRunLoopThread.m:70)
11 Foundation NSThread__start + 1040
12 libsystem_pthread.dylib _pthread_body + 272
13 libsystem_pthread.dylib _pthread_body + 0
this crash found online
Activity
LoveLifeLoveSelf commentedon Aug 27, 2018
@kommen @lukeredpath @xaviershay @danielrhammond @mk Ask for help,thanks! #
MikeWeller commentedon Nov 28, 2018
The SRProxyConnect class is rather unsafe around NSStream lifetime and event dispatches. There have been similar issues in the past with SRWebSocket but those fixed haven't made it to SRProxyConnect.
The input and output streams must both be scheduled on the
SR_networkRunLoop
run loop (currently only the inputstream is, with a commented out line for the output stream which has been there since the class was created). In addition, the closing, nil-ing out of instance variables, and nil-ing out of the delegates for those streams must be performed on that same runloop, otherwise the streams themselves can end up getting deallocated while events are being processed, or the delegate (SRProxyConnect itself) can end up getting deallocated while events are being processed, since the streams keep a non-retained reference to it.So, although I haven't got round to submitting my fix for this:
SR_networkRunLoop
similar to how theinputStream
already is, by uncommenting thescheduleInRunLoop
call. Also add a call to unschedule in the appropriate place (search for the input stream one).SR_networkRunLoop
to be actioned, to ensure there can be no events being processed concurrently and that after clearing the streams' delegate SRProxyConnect itself can happily die and turn into trash memory without any more queued or still-running events getting processed. You can execute something on the correct thread/runloop with:MikeWeller commentedon Nov 28, 2018
Pasting some raw notes from a crash analysis I did:
MikeWeller commentedon Nov 28, 2018
To further clarify what I think is happening:
failWithError
and we end up throwing away the input stream and output streams by assigning them to nil.codingingBoy commentedon Oct 10, 2022
So is there a conclusion for this? I received more and more this crash for my app these days.
iamsaadMehmood commentedon Nov 12, 2024
I am also getting this crash issue in Firebase Crashlytics.
Did someone find a solution for this Crash?