Skip to content

Crash in WebSocket.processInputStream() #367

Closed
@kilyukhin

Description

@kilyukhin

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 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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions