Exception when closing LLCP socket from both sides simultaneously.

Bug #705757 reported by Alexander Knaub
12
This bug affects 2 people
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_readerwriter.py", line 702, in CloseSocket
    socket.close()
  File ".../nfcpy/nfc/llcp/tco.py", line 515, in close
    pdu = super(DataLinkConnection, self).recv()
  File ".../nfcpy/nfc/llcp/tco.py", line 122, in recv
    return self.recv_queue.popleft()
IndexError: pop from an empty deque

Tags: close llcp socket

Related branches

tags: added: llcp
Revision history for this message
Alexander Knaub (sanyok-og) wrote :

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.

Revision history for this message
Stephen Tiedemann (stephen-tiedemann) wrote :

Need to setup a test case to confirm this bug.

Changed in nfcpy:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Stephen Tiedemann (stephen-tiedemann) wrote :

This was fixed long time but missed to close the bug report.

Changed in nfcpy:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.