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
The problem reported in issue #363 happens in my released app. Looks like there is a concurrency issue inside the library code.
WebSocket.processInputStream is called from WebSocket.stream delegate in a background thread. While the function is being executed, a client code may call WebSocket.disconnect in main queue. So it could happen that between WebSocket.processInputStream start and let length = inputStream!.read(buffer, maxLength: BUFFER_MAX) line inputStream becomes nil and inputStream! unwrapping crashes.
Client code has no access to WebSocket.stream thread and hence has no way to avoid this issue from happening.
Does it make sense to dispatch WebSocket.stream body execution to main queue?
The text was updated successfully, but these errors were encountered:
I’m seeing this issue as well and came to the same conclusion as @kilyukhin. There also seems to be a similar race condition for cleanupStream() where the stream.close() call results in a crash due to CFHash(_:) being given NULL.
Hi,
The problem reported in issue #363 happens in my released app. Looks like there is a concurrency issue inside the library code.
WebSocket.processInputStream
is called fromWebSocket.stream
delegate in a background thread. While the function is being executed, a client code may callWebSocket.disconnect
in main queue. So it could happen that betweenWebSocket.processInputStream
start andlet length = inputStream!.read(buffer, maxLength: BUFFER_MAX)
lineinputStream
becomesnil
andinputStream!
unwrapping crashes.Client code has no access to
WebSocket.stream
thread and hence has no way to avoid this issue from happening.Does it make sense to dispatch
WebSocket.stream
body execution to main queue?The text was updated successfully, but these errors were encountered: