This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_importlib creates a coredump on AMD64 FreeBSD 10.x Shared 3.7
Type: Stage: resolved
Components: FreeBSD, Tests Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: koobs, miss-islington, ncoghlan, petr.viktorin, vstinner
Priority: normal Keywords: patch

Created on 2018-05-24 01:38 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 7090 merged vstinner, 2018-05-24 02:13
PR 7101 merged miss-islington, 2018-05-24 20:20
PR 7102 merged miss-islington, 2018-05-24 20:21
Messages (6)
msg317497 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-05-24 01:38
http://buildbot.python.org/all/#/builders/124/builds/315

Warning -- files was modified by test_importlib
  Before: []
  After:  ['python.core']
msg317504 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-05-24 02:08
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
(...)
msg317507 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-05-24 02:16
The test creating the coredump has been added by bpo-32374.
msg317614 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-05-24 20:19
New changeset 483000e164ec68717d335767b223ae31b4b720cf by Victor Stinner in branch 'master':
bpo-33629: Prevent coredump in test_importlib (GH-7090)
https://github.com/python/cpython/commit/483000e164ec68717d335767b223ae31b4b720cf
msg317620 - (view) Author: miss-islington (miss-islington) Date: 2018-05-24 20:44
New changeset d9eb22c67c38b45764dd924801c72092770d200f by Miss Islington (bot) in branch '3.7':
bpo-33629: Prevent coredump in test_importlib (GH-7090)
https://github.com/python/cpython/commit/d9eb22c67c38b45764dd924801c72092770d200f
msg317624 - (view) Author: miss-islington (miss-islington) Date: 2018-05-24 21:07
New changeset fc0356d2a34719df517a5056bf1a3709850776cf by Miss Islington (bot) in branch '3.6':
bpo-33629: Prevent coredump in test_importlib (GH-7090)
https://github.com/python/cpython/commit/fc0356d2a34719df517a5056bf1a3709850776cf
History
Date User Action Args
2022-04-11 14:59:00adminsetgithub: 77810
2018-05-24 22:24:32vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-05-24 21:07:46miss-islingtonsetmessages: + msg317624
2018-05-24 20:44:59miss-islingtonsetnosy: + miss-islington
messages: + msg317620
2018-05-24 20:21:52miss-islingtonsetpull_requests: + pull_request6740
2018-05-24 20:20:55miss-islingtonsetpull_requests: + pull_request6738
2018-05-24 20:19:36vstinnersetmessages: + msg317614
2018-05-24 19:47:31brett.cannonsetnosy: + ncoghlan, petr.viktorin
2018-05-24 02:16:20vstinnersetmessages: + msg317507
2018-05-24 02:13:45vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request6725
2018-05-24 02:08:35vstinnersetmessages: + msg317504
2018-05-24 01:38:15vstinnercreate