Uh oh!
There was an error while loading. Please reload this page.
gh-132775: Expand the Capability of Interpreter.call() - #133484
Conversation
4fdc11a to
4327098Compare27d83f1 to
f9f7666Comparef9f7666 to
b8171d9Compare| def call(self, callable, /, *args, **kwargs): | ||
| """Call the object in the interpreter with given args/kwargs. | ||
| Only functions that take no arguments and have no closure |
There was a problem hiding this comment.
The docstring looks partially outdated (here or in Lib/interpreters/__init__.py). The same would apply for _interpretersmodule.c?
d58f54e to
4152f17Compare4152f17 to
d173ec0Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
This review focuses on the refleaks in test_api (Py_GIL_DISABLED seems to skip the test).
_PyFunction_VerifyStateless:
Line 1267 in 0d499c7
PyDict_Size(defaults)needsPyDict_Check()or_PyErr_Clear().- The same goes for
PyDict_Size(kwdefaults)at L1275.
| struct interp_call temp = *call; | ||
| *call = (struct interp_call){0}; | ||
| if (temp.func != NULL) { | ||
| _PyXIData_Clear(NULL, temp.func); |
There was a problem hiding this comment.
_PyXIData_Clear() here does not work expectedly on MSVC.
structinterp_calltemp=*call;
printf("before: %p %p %p\n", temp.func, temp.func->data, temp.func->obj);
*call= (structinterp_call){0};
printf("after : %p %p %p\n", temp.func, temp.func->data, temp.func->obj);
before: 0000000000C3CF5800000000057763B00000000002BFCEF0after : 0000000000C3CF5800000000000000000000000000000000There was a problem hiding this comment.
Yeah, the logic here is wrong because the pointers in temp point to the call fields, which have been nulled out. I'm fixing that.
| PyObject *exc = _PyErr_GetRaisedException(tstate); | ||
| if (_PyPickle_GetXIData(tstate, func, &call->_preallocated.func) < 0) { | ||
| _PyErr_SetRaisedException(tstate, exc); | ||
| //unwrap_not_shareable(tstate); | ||
| return -1; | ||
| } |
There was a problem hiding this comment.
Py_DECREF(exc) seems missing after L472.
| } | ||
| _PyXI_FreeSession(session); | ||
| return res; |
There was a problem hiding this comment.
Py_CLEAR(result.preserved) before L665 seems effective?
| PyObject *func, *args, *kwargs; | ||
| if (_interp_call_unpack(call, &func, &args, &kwargs) == 0) { | ||
| // Either the problem is intermittent or only affects subinterpreters. | ||
| // This is highly unlikely. |
There was a problem hiding this comment.
Py_DECREF(func); Py_DECREF(args); Py_XDECREF(kwargs);?
| if (kwargs_obj != NULL) { | ||
| _PyErr_SetString(tstate, PyExc_ValueError, "got unexpected kwargs"); | ||
| struct interp_call call = {0}; | ||
| if (_interp_call_pack(tstate, &call, callable, args_obj, kwargs_obj) < 0) { |
There was a problem hiding this comment.
_interp_call_clear(&call) in the branch?
Nice catch. I also got it wrong with |
ericsnowcurrently
commented
May 29, 2025
!buildbot AMD64 Fedora Stable Refleaks |
bedevere-bot
commented
May 29, 2025
🤖 New build scheduled with the buildbot fleet by @ericsnowcurrently for commit 17beeda 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F133484%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
ericsnowcurrently
commented
May 29, 2025
@neonene, thanks again for all the help chasing down leaks! You saved me a bunch of time. |
ericsnowcurrently
commented
May 29, 2025
Unless there are any objections, I'll merge this first thing in the morning (~16:00 UTC). |
Thanks @ericsnowcurrently for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
GH-134933 is a backport of this pull request to the 3.14 branch. |
…h-133484) It now supports most callables, full args, and return values.
…h-133484) It now supports most callables, full args, and return values.
…h-133484) It now supports most callables, full args, and return values.
It now supports most callables, full args, and return values.