tidwall / SwiftWebSocket

Fast Websockets in Swift for iOS and OSX
MIT License
1.53k stars 246 forks source link

Data race #158

Open Usipov opened 3 years ago

Usipov commented 3 years ago

Number 1

Screenshot 2021-04-19 at 19 23 47 Screenshot 2021-04-19 at 19 24 04
WARNING: ThreadSanitizer: Swift access race (pid=97366)
  Modifying access of Swift variable at 0x7b2800038ce0 by thread T3:
    #0 closure #1 in Manager.init() <null>:2 (App:x86_64+0x10212d834)
    #1 partial apply for closure #1 in Manager.init() <null>:2 (App:x86_64+0x102131a8d)
    #2 thunk for @escaping @callee_guaranteed () -> () <null>:2 (App:x86_64+0x1000d8ea3)
    #3 __tsan::invoke_and_release_block(void*) <null>:2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x70ebb)
    #4 _dispatch_client_callout <null>:2 (libdispatch.dylib:x86_64+0x39c7)

  Previous modifying access of Swift variable at 0x7b2800038ce0 by thread T13 (mutexes: write M2419):
    #0 Manager.nextId() <null>:2 (App:x86_64+0x10212fb11)
    #1 WebSocket.init(request:subProtocols:) <null>:2 (App:x86_64+0x102134676)
    #2 @objc WebSocket.init(request:subProtocols:) <null>:2 (App:x86_64+0x102135129)
    #3 WebSocket.init() <null>:2 (App:x86_64+0x102135613)
    #4 @objc WebSocket.init() <null>:2 (App:x86_64+0x1021356fb)
    #5 WebSocket.__allocating_init() <null>:2 (App:x86_64+0x1021351cd)
    #6 WebSocketFactoryImpl.makeWebSocket() <null>:2 (App:x86_64+0x101725335)

Number 2

Screenshot 2021-04-19 at 19 28 14 Screenshot 2021-04-19 at 19 28 36
WARNING: ThreadSanitizer: Swift access race (pid=97366)
  Modifying access of Swift variable at 0x7b5400099498 by main thread:
    #0 InnerWebSocket.lock() <null>:2 (App:x86_64+0x1020ef405)
    #1 InnerWebSocket.privateReadyState.getter <null>:2 (App:x86_64+0x1020ea7ab)
    #2 InnerWebSocket.readyState.getter <null>:2 (App:x86_64+0x1020ea718)
    #3 WebSocket.readyState.getter <null>:2 (App:x86_64+0x102137137)

  Previous modifying access of Swift variable at 0x7b5400099498 by thread T3 (mutexes: write M50187, write M50210):
    #0 InnerWebSocket.unlock() <null>:2 (App:x86_64+0x1020ef4e5)
    #1 $defer #1 () in InnerWebSocket.dirty.getter <null>:2 (App:x86_64+0x1020f0f4d)
    #2 InnerWebSocket.dirty.getter <null>:2 (App:x86_64+0x1020f0eb6)
    #3 closure #1 in Manager.init() <null>:2 (App:x86_64+0x10212dbc4)
    #4 partial apply for closure #1 in Manager.init() <null>:2 (App:x86_64+0x102131a8d)
    #5 thunk for @escaping @callee_guaranteed () -> () <null>:2 (App:x86_64+0x1000d8ea3)
    #6 __tsan::invoke_and_release_block(void*) <null>:2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x70ebb)
    #7 _dispatch_client_callout <null>:2 (libdispatch.dylib:x86_64+0x39c7)