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

Prevent crash caused by non-exclusive access to the Channels array #255

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

ejensen
Copy link
Contributor

@ejensen ejensen commented Apr 16, 2024

This PR fixes a threading issue where the Socket.channels array is being mutated while it is being iterated. This PR wraps channels in a SynchronizedArray to resolve this issue.

Crash stack trace:

SIGTRAP

Crashed: com.apple.NSURLSession-delegate
0  Frame.io                   0x1779e18 specialized _ArrayProtocol.filter(_:) + 714 (Socket.swift:714)
1  Frame.io                   0x17765a0 Socket.onConnectionMessage(_:) + 713 (Socket.swift:713)
2  Frame.io                   0x1777d84 protocol witness for PhoenixTransportDelegate.onMessage(message:) in conformance Socket + 860 (Socket.swift:860)
3  Frame.io                   0x1768e34 closure #1 in URLSessionTransport.receive() + 283 (PhoenixTransport.swift:283)
4  Foundation                 0x3aadec closure #1 in NSURLSessionWebSocketTask.receive(completionHandler:) + 144
5  Foundation                 0x3aaf80 thunk for @escaping @callee_guaranteed @Sendable (@guaranteed NSURLSessionWebSocketMessage?, @guaranteed Error?) -> () + 84
6  libdispatch.dylib          0x213c _dispatch_call_block_and_release + 32
7  libdispatch.dylib          0x3dd4 _dispatch_client_callout + 20
8  libdispatch.dylib          0xb400 _dispatch_lane_serial_drain + 748
9  libdispatch.dylib          0xbf64 _dispatch_lane_invoke + 432
10 libdispatch.dylib          0x16cb4 _dispatch_root_queue_drain_deferred_wlh + 288
11 libdispatch.dylib          0x16528 _dispatch_workloop_worker_thread + 404
12 libsystem_pthread.dylib    0x1f20 _pthread_wqthread + 288
13 libsystem_pthread.dylib    0x1fc0 start_wqthread + 8

@dsrees dsrees merged commit 7d23b4a into davidstump:master Apr 17, 2024
@ejensen
Copy link
Contributor Author

ejensen commented Jul 23, 2024

@dsrees Would it be possible to create a 5.3.3 tag with this fix included?

@dsrees
Copy link
Collaborator

dsrees commented Jul 24, 2024

Yes, sorry. I'll try to get to that soon

@dsrees
Copy link
Collaborator

dsrees commented Jul 30, 2024

@ejensen Thank you for your patience. 5.3.3 should now be available

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

Successfully merging this pull request may close these issues.

2 participants