cpyext: vector calls that raise exceptions leak reference to arguments
Dear PyPy team (& @mattip),
this is the last one, I promise! (ducks)
When PyPy delivers a vector call to a CPython extension via tp_vectorcall_offset
, and when that vector call then raises an exception, there is some kind of reference counting issue. My tests indicate that the arguments are simply leaked.
Reproducer: https://github.com/wjakob/pypy_issues/blob/master/issue_9.py and https://github.com/wjakob/pypy_issues/blob/master/pypy_issues.c#L69
This uses the wrapper
class from #3849 just out of convenience (it prints a message when an instance is created and destroyed).
Expected output:
$ python issue_9.py
wrapper tp_init called.
wrapper tp_dealloc called.
PyPy output:
$ pypy issue_9.py
wrapper tp_init called.
I also tried normal function calls via PyMethodDef
, and those work fine. I suspect it's something specifically about the implementation of vector calls.