Author pablogsal
Recipients pablogsal, pitrou, vstinner
Date 2019-09-02.13:56:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1567432593.55.0.481148483159.issue38009@roundup.psfhosted.org>
In-reply-to
Content
A weak reference may try to invoke a callback object that is being
cleaned (tp_clear) by the garbage collector and it may be in an
inconsistent state. As the garbage collector explicitly does not
invoke callbacks that are part of the same cycle isolate as the
weak reference (pretending that the weak reference was destroyed first),
we should act in the same way when invoking callbacks using Objects/weakrefobject.c:handle_callback.

For example, consider the following scenario:

- F is a function.
- An object O is in a cycle with F.
- O has a weak reference with F as a callback.

When running the garbage collector, is possible to end in Objects/weakrefobject.c:handle_callback if the tp_clear of F decrements the references of O, invoking the weak
reference callback that will try to call F, which is in an incosistent
state as is in the middle of its tp_clear and some internal fields may
be NULL.
History
Date User Action Args
2019-09-02 13:56:33pablogsalsetrecipients: + pablogsal, pitrou, vstinner
2019-09-02 13:56:33pablogsalsetmessageid: <1567432593.55.0.481148483159.issue38009@roundup.psfhosted.org>
2019-09-02 13:56:33pablogsallinkissue38009 messages
2019-09-02 13:56:33pablogsalcreate