Message360129
| Author |
vstinner |
| Recipients |
dino.viehland, eric.snow, pablogsal, twouters, vstinner |
| Date |
2020年01月16日.16:47:11 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1579193232.09.0.907128999433.issue38076@roundup.psfhosted.org> |
| In-reply-to |
| Content |
I can reproduce the crash on Linux. I interrupt the problem with CTRL+c (why is it blocked? I don't know). Then it does crash.
First, _PyImport_Cleanup() does clear all modules including _struct.
Then, _PyImport_Cleanup() calls gc.collect() which finalize_garbage() which calls A.__del__().
Problem: at this point, the _struct became unusable.
--
Thread 1 "python" received signal SIGSEGV, Segmentation fault.
0x0000000000473f30 in PyModule_GetState (m=0x0) at Objects/moduleobject.c:565
565 if (!PyModule_Check(m)) {
(gdb) py-bt
Traceback (most recent call first):
<built-in method pack of module object at remote 0x7fffea99acb0>
File "/home/vstinner/python/master/Lib/multiprocessing/connection.py", line 400, in _send_bytes
header = struct.pack("!i", n)
File "/home/vstinner/python/master/Lib/multiprocessing/connection.py", line 200, in send_bytes
self._send_bytes(m[offset:offset + size])
File "/home/vstinner/python/master/Lib/multiprocessing/queues.py", line 368, in put
self._writer.send_bytes(obj)
File "/home/vstinner/python/master/Lib/multiprocessing/pool.py", line 649, in close
self._change_notifier.put(None)
File "/home/vstinner/python/master/x.py", line 7, in __del__
self.pool.close()
Garbage-collecting
In debug mode, the crash occurs in s_pack() at:
assert(PyStruct_Check(self));
--
#define _structmodulestate(o) ((_structmodulestate *)PyModule_GetState(o))
static struct PyModuleDef _structmodule;
#define _structmodulestate_global _structmodulestate(PyState_FindModule(&_structmodule))
#define PyStruct_Check(op) PyObject_TypeCheck(op, (PyTypeObject *)_structmodulestate_global->PyStructType)
The problem is "_structmodulestate_global->PyStructType": PyState_FindModule(&_structmodule) returns NULL, _structmodulestate() calls PyModule_GetState(NULL) which does crash.
--
The question is why the _struct module was cleared whereas there was still a reference to it. Is it part of a reference cycle? |
|