You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#130708 introduces stackrefs whose lifetime must be shorter than the lifetime of another stackref. We should verify this property in the debug build of stackrefs: warn anytime a stackref with outstanding borrowed references is closed.
Here is a sketch of a possible implementation:
Add a counter, borrows, to each stackref that records the number of borrows.
Add a borrowed_from field to each stackref that records the index of the stackref it was borrowed from, if any. This field is preserved by PyStackRef_DUP.
PyStackRef_Borrow(from) sets the the borrowed_from field on the returned stackref and increments the borrows field on from. We should follow chains of borrows until we reach the unborrowed reference at the head.
PyStackRef_CLOSE on a borrowed stackref decrements the borrows field on the borrowed-from stackref.
PyStackRef_CLOSE warns if borrows is non-zero.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
The text was updated successfully, but these errors were encountered:
Feature or enhancement
Proposal:
#130708 introduces stackrefs whose lifetime must be shorter than the lifetime of another stackref. We should verify this property in the debug build of stackrefs: warn anytime a stackref with outstanding borrowed references is closed.
Here is a sketch of a possible implementation:
borrows
, to each stackref that records the number of borrows.borrowed_from
field to each stackref that records the index of the stackref it was borrowed from, if any. This field is preserved byPyStackRef_DUP
.PyStackRef_Borrow(from)
sets the theborrowed_from
field on the returned stackref and increments theborrows
field onfrom
. We should follow chains of borrows until we reach the unborrowed reference at the head.PyStackRef_CLOSE
on a borrowed stackref decrements theborrows
field on the borrowed-from stackref.PyStackRef_CLOSE
warns ifborrows
is non-zero.Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
The text was updated successfully, but these errors were encountered: