The problem comes from MultiPhaseExtensionModuleTests.test_bad_traverse() of Lib/test/test_importlib/extension/test_loader.py.
This test runs the following code:
---
import importlib.util as util
spec = util.find_spec('_testmultiphase')
spec.name = '_testmultiphase_with_bad_traverse'
m = spec.loader.create_module(spec)
---
I confirm that this script does crash and may generate a core dump:
vstinner@apu$ ./python x.py
Segmentation fault (core dumped)
Python traceback of the crash:
(gdb) py-bt
Traceback (most recent call first):
<built-in method create_dynamic of module object at remote 0x7ffff7f37458>
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 1043, in create_module
File "x.py", line 4, in <module>
m = spec.loader.create_module(spec)
C traceback:
Program received signal SIGSEGV, Segmentation fault.
0x00007fffeffb69f3 in bad_traverse (self=<module at remote 0x7ffff7e59658>, visit=0x481b4d <bad_traverse_test>, arg=0x0)
at /home/vstinner/prog/python/master/Modules/_testmultiphase.c:628
628 Py_VISIT(m_state->integer);
(gdb) where
#0 0x00007fffeffb69f3 in bad_traverse (self=<module at remote 0x7ffff7e59658>, visit=0x481b4d <bad_traverse_test>, arg=0x0)
at /home/vstinner/prog/python/master/Modules/_testmultiphase.c:628
#1 0x0000000000482866 in PyModule_FromDefAndSpec2TraceRefs (def=0x7ffff01b8ce0 <def_with_bad_traverse>,
spec=<ModuleSpec(name='_testmultiphase_with_bad_traverse', loader=<ExtensionFileLoader(name='_testmultiphase', path='/home/vstinner/prog/python/master/build/lib.linux-x86_64-3.8-pydebug/_testmultiphase.cpython-38dm-x86_64-linux-gnu.so') at remote 0x7ffff04632c8>, origin='/home/vstinner/prog/python/master/build/lib.linux-x86_64-3.8-pydebug/_testmultiphase.cpython-38dm-x86_64-linux-gnu.so', loader_state=None, submodule_search_locations=None, _set_fileattr=True, _cached=None) at remote 0x7ffff0463330>, module_api_version=1013) at Objects/moduleobject.c:366
#2 0x000000000057ed89 in _PyImport_LoadDynamicModuleWithSpec (
spec=<ModuleSpec(name='_testmultiphase_with_bad_traverse', loader=<ExtensionFileLoader(name='_testmultiphase', path='/home/vstinner/prog/python/master/build/lib.linux-x86_64-3.8-pydebug/_testmultiphase.cpython-38dm-x86_64-linux-gnu.so') at remote 0x7ffff04632c8>, origin='/home/vstinner/prog/python/master/build/lib.linux-x86_64-3.8-pydebug/_testmultiphase.cpython-38dm-x86_64-linux-gnu.so', loader_state=None, submodule_search_locations=None, _set_fileattr=True, _cached=None) at remote 0x7ffff0463330>, fp=0x0) at ./Python/importdl.c:193
#3 0x000000000057df53 in _imp_create_dynamic_impl (module=<module at remote 0x7ffff7f37458>,
spec=<ModuleSpec(name='_testmultiphase_with_bad_traverse', loader=<ExtensionFileLoader(name='_testmultiphase', path='/home/vstinner/prog/python/master/build/lib.linux-x86_64-3.8-pydebug/_testmultiphase.cpython-38dm-x86_64-linux-gnu.so') at remote 0x7ffff04632c8>, origin='/home/vstinner/prog/python/master/build/lib.linux-x86_64-3.8-pydebug/_testmultiphase.cpython-38dm-x86_64-linux-gnu.so', loader_state=None, submodule_search_locations=None, _set_fileattr=True, _cached=None) at remote 0x7ffff0463330>, file=0x0) at Python/import.c:2174
#4 0x000000000057789f in _imp_create_dynamic (module=<module at remote 0x7ffff7f37458>, args=0x7ffff7f1f630, nargs=1) at Python/clinic/import.c.h:289
(...)
|