The use of PyStackRef_AsPyObjectBorrow
makes it hard to track ownership of references, making analysis of escaping calls too difficult
#122034
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
Uh oh!
There was an error while loading. Please reload this page.
The problem with
PyStackRef_AsPyObjectBorrow
is that it is not clear whether the reference is owned by the stack ref or the pointer.Borrowing references across calls is fine but in less structured code, it is error prone and very hard to analyze.
The solution is change most, ideally all, uses of
PyStackRef_AsPyObjectBorrow
toPyStackRef_AsPyObjectSteal
so that the ownership of the reference is clear.E.g.
would become:
This ensures that during the escaping call to
PyNumber_Negative
, the reference to thevalue
aPyObject *
, so will not be reclaimed by the garbage collector.Linked PRs
The text was updated successfully, but these errors were encountered: