-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
reference counter issue in signal module #82218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Adding these two lines to /Objects/longobject.c will disable the "preallocated small integer pool": #define NSMALLPOSINTS 0
#define NSMALLNEGINTS 0 Then run this reproduce code (attached): from enum import IntEnum
import _signal
class Handlers(IntEnum):
A = _signal.SIG_DFL
B = _signal.SIG_IGN When the interpreter exits, will get this error:
3.8 and 3.9 branches are affected. |
I did a Git bisect, this is the first bad commit: nosy involved mates. |
This issue is a Python 3.8 regression. Joannah: Would you mind to have a look? x = DefaultHandler = PyLong_FromVoidPtr((void *)SIG_DFL);
if (PyModule_AddObject(m, "SIG_DFL", x))
goto finally; This change is not easy to read. DefaultHandler must be a strong reference: finisignal() calls Py_CLEAR(DefaultHandler); Previously, the code uses PyDict_SetItemString(d, "SIG_DFL", x): PyDict_SetItemString increases the reference counter, whereas PyModule_AddObject leaves the reference counter unchanged (yeah, it's a strange/bad C API). I guess than an INCREF() is needed somewhere. Compare it to: int
PyModule_AddIntConstant(PyObject *m, const char *name, long value)
{
PyObject *o = PyLong_FromLong(value);
if (!o)
return -1;
if (PyModule_AddObject(m, name, o) == 0)
return 0;
Py_DECREF(o);
return -1;
} |
I will look after my next meeting which is in 10 minutes. In the meantime have you perused this PR : #15701 If it can solve this? |
Thanks for the fix animalize. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: