Code

Opened 17 months ago

Closed 5 months ago

#19947 closed Bug (duplicate)

weakref'd signal receivers may cause deadlock when gc'd

Reported by: john@… Owned by:
Component: Core (Other) Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

By default when a receiver is connected to a Signal it is wrapped in a saferef has a call back to Signal._remove_reciever when gc'd.

Inside, _remove_receiver it acquires a lock on itself before proceeding to delete the reference of the receiver from the signal.
To find the receiver, the receiver list is reversed. This generates a new listreverseiterator to be created. In turn, this can may cause a GC to run. Which clears all unreachable weakrefs, one of which may be another receiver connected to the same signal. The gc calls the callback on this receiver (_remove_receiver) and hits a deadlock on trying to acquire the Lock again.

Attachments (0)

Change History (5)

comment:1 Changed 16 months ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Do you have some code that can reproduce this?

comment:2 Changed 14 months ago by nott

  • Owner changed from nobody to nott
  • Status changed from new to assigned

comment:3 Changed 13 months ago by john@…

I've been trying to come up with some code to reliable reproduce this, so far I've been unsuccessful. I will continue to try though.

comment:4 Changed 12 months ago by nott

  • Owner nott deleted
  • Status changed from assigned to new

comment:5 Changed 5 months ago by akaariai

  • Resolution set to duplicate
  • Status changed from new to closed

I am marking this as duplicate of #21952, that ticket contains a patch for this issue.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.