Exception when closing LLCP socket from both sides simultaneously.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
nfcpy |
Fix Released
|
Medium
|
Unassigned |
Bug Description
If an LLCP socket is closed by both, acceptor and connector at the same time, in LLCP occurs an uncaught exception "IndexError: pop from an empty deque".
LLCP log and error traceback are listed below.
LLCP: Incoming request for closing socket with id 138735756.
LLCP: Socket in the table: DLC 16 <-> 32 ESTABLISHED RW(R)=1 V(S)=1 V(SA)=0 RW(L)=1 V(R)=1 V(RA)=1
DLC (16,32) close() in state ESTABLISHED
RECV 0 -> 0 SYMM
DLC (16,32) dequeued DISC PDU
SEND 16 -> 32 DISC
RECV 32 -> 16 DISC
DLC (16,32) enqueue DISC
SEND 0 -> 0 SYMM
From this moment on, only symmetry packets are exchanged and there are no further entries considering this socket but an exception occurs:
File "./dbus_
socket.close()
File ".../nfcpy/
pdu = super(DataLinkC
File ".../nfcpy/
return self.recv_
IndexError: pop from an empty deque
Related branches
tags: | added: llcp |
It seems like the reason for this bug is similar to that for the bug #710581.
When on a DataLinkConnection object close() is called and state is ESTABLISHED, it sends a DISC-PDU, changes the state to DISCONNECT and waits for an answer in the recv() method before calling super's close().
If remote side terminates connection inbetween or if link is broken, state is DISCONNECT when close() is called by LLC. So, no DISC is sent, but super's close() is called directly. This leads to clearing the receiving buffer and notifying all the waiting threads. Consequence is that the previously started closing thread wakes up and tries to read from empty queue.