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

Replicator not getting stopped when using MessageEndpoint #2188

Closed
pasin opened this Issue Jul 28, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@pasin
Contributor

pasin commented Jul 28, 2018

This is found by @sridevi-15 that when using MessageEndpoint the replicator stays in BUSY state after calling replicator.stop(). From the stack trace below, there is a deadlock caused by recursive logging on non-reentrance lock from [1] getting websocket close handshake and [2] later from socket_closed() acknowledgement.

  thread #6, queue = 'ReplicatorTcpClientConnection'
    frame #0: 0x000000018241113c libsystem_kernel.dylib`__psynch_mutexwait + 8
    frame #1: 0x00000001825b4604 libsystem_pthread.dylib`_pthread_mutex_lock_wait + 96
    frame #2: 0x00000001825b4550 libsystem_pthread.dylib`_pthread_mutex_lock_slow$VARIANT$mp + 260
    frame #3: 0x0000000181afbfc4 libc++.1.dylib`std::__1::mutex::lock() + 12
    frame #4: 0x00000001009a1e20 CouchbaseLiteSwift`litecore::websocket::WebSocketImpl::onClose(litecore::websocket::CloseStatus) + 48
    frame #5: 0x000000010081ae90 CouchbaseLiteSwift`c4socket_closed + 192
    frame #6: 0x00000001007afd30 CouchbaseLiteSwift`___lldb_unnamed_symbol2757$$CouchbaseLiteSwift + 364
    frame #7: 0x00000001007839d0 CouchbaseLiteSwift`___lldb_unnamed_symbol1529$$CouchbaseLiteSwift + 16
    frame #8: 0x00000001007838d4 CouchbaseLiteSwift`___lldb_unnamed_symbol1527$$CouchbaseLiteSwift + 128
    frame #9: 0x0000000100373e44 TestTcpP2P`ReplicatorTcpClientConnection.close(error=nil, completion=0x0000000100784354 CouchbaseLiteSwift`___lldb_unnamed_symbol1557$$CouchbaseLiteSwift, self=0x0000000102a50120) at ReplicatorTcpClientConnection.swift:136
    frame #10: 0x000000010037447c TestTcpP2P`protocol witness for MessageEndpointConnection.close(error:completion:) in conformance ReplicatorTcpClientConnection at ReplicatorTcpClientConnection.swift:0
    frame #11: 0x0000000100783834 CouchbaseLiteSwift`___lldb_unnamed_symbol1526$$CouchbaseLiteSwift + 268
    frame #12: 0x00000001007839a8 CouchbaseLiteSwift`___lldb_unnamed_symbol1528$$CouchbaseLiteSwift + 196
    frame #13: 0x00000001007b0324 CouchbaseLiteSwift`___lldb_unnamed_symbol2768$$CouchbaseLiteSwift + 188
    frame #14: 0x00000001009a1328 CouchbaseLiteSwift`litecore::websocket::WebSocketImpl::receivedClose(fleece::slice) + 112
    frame #15: 0x00000001009a0ed8 CouchbaseLiteSwift`litecore::websocket::WebSocketImpl::handleFragment(char*, unsigned long, unsigned int, int, bool) + 208
    frame #16: 0x00000001009a162c CouchbaseLiteSwift`___lldb_unnamed_symbol5711$$CouchbaseLiteSwift + 308
    frame #17: 0x000000010099f4c4 CouchbaseLiteSwift`uWS::WebSocketProtocol<false>::_consume(char*, unsigned int, void*) + 392
    frame #18: 0x000000010099f1f0 CouchbaseLiteSwift`litecore::websocket::WebSocketImpl::onReceive(fleece::slice) + 424
    frame #19: 0x000000010081afa4 CouchbaseLiteSwift`c4socket_received + 16
    frame #20: 0x00000001007af944 CouchbaseLiteSwift`___lldb_unnamed_symbol2753$$CouchbaseLiteSwift + 160
    frame #21: 0x0000000100784054 CouchbaseLiteSwift`___lldb_unnamed_symbol1539$$CouchbaseLiteSwift + 120
    frame #22: 0x0000000100784110 CouchbaseLiteSwift`___lldb_unnamed_symbol1543$$CouchbaseLiteSwift + 28
    frame #23: 0x00000001003752dc TestTcpP2P`ReplicatorTcpClientConnection.receiveBytes(buffer=0x0000000103002200, length=4, self=0x0000000102a50120) at ReplicatorTcpClientConnection.swift:224
    frame #24: 0x0000000100374874 TestTcpP2P`ReplicatorTcpClientConnection.doRead(self=0x0000000102a50120) at ReplicatorTcpClientConnection.swift:214
    frame #25: 0x0000000100374514 TestTcpP2P`ReplicatorTcpClientConnection.stream(aStream=0x0000000102a52690, eventCode=[.none, .hasBytesAvailable], self=0x0000000102a50120) at ReplicatorTcpClientConnection.swift:161
    frame #26: 0x0000000100374eb4 TestTcpP2P`@objc ReplicatorTcpClientConnection.stream(_:handle:) at ReplicatorTcpClientConnection.swift:0
    frame #27: 0x00000001828c3b34 CoreFoundation`_signalEventSync + 212
    frame #28: 0x0000000182941ea4 CoreFoundation`___signalEventQueue_block_invoke + 24
    frame #29: 0x00000001027391dc libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #30: 0x000000010273919c libdispatch.dylib`_dispatch_client_callout + 16
    frame #31: 0x0000000102747dfc libdispatch.dylib`_dispatch_queue_serial_drain + 768
    frame #32: 0x000000010273c6ac libdispatch.dylib`_dispatch_queue_invoke + 328
    frame #33: 0x0000000102748d54 libdispatch.dylib`_dispatch_root_queue_drain_deferred_wlh + 352
    frame #34: 0x000000010274fe38 libdispatch.dylib`_dispatch_workloop_worker_thread + 676
    frame #35: 0x00000001825afe70 libsystem_pthread.dylib`_pthread_wqthread + 860
    frame #36: 0x00000001825afb08 libsystem_pthread.dylib`start_wqthread + 4


  • Version: 2.1.0 RC3

@pasin pasin self-assigned this Jul 28, 2018

@pasin pasin added this to the 2.1.0 milestone Jul 28, 2018

@pasin pasin closed this Jul 31, 2018

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