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: imp.find_module of a .py ending dir causes glibc double free crash
Type: crash Stage: test needed
Components: Interpreter Core Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: imp.find_module crashes Python if there exists a directory named "__init__.py"
View: 7732
Assigned To: Nosy List: brett.cannon, doko, flox, l0nwlf, ncoghlan, orsenthil
Priority: high Keywords:

Created on 2010-04-09 01:11 by doko, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg102662 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2010-04-09 01:11
[forwarded from http://bugs.debian.org/577005]

seen with 2.5.5, 2.6.5 and 2.7alpha4:

The imp.find_module function causes a glibc double free or corruption if
it would be invoked with a directory with a ".py" ending. It can be
reproduced with:

mkdir bla.py; python -c 'import imp; imp.find_module("bla", ["."])'

This causes bpython to crash after the first input char if such a
directory exist.


stacktrace with 2.6.5:
(gdb) bt
#0  0x00355906 in *__GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00358e05 in *__GI_abort () at abort.c:88
#2  0x0038c78d in __libc_message (do_abort=2, fmt=0x453088 "*** glibc detected *** %s: %s: 0x%s ***\n")
    at ../sysdeps/unix/sysv/linux/libc_fatal.c:173
#3  0x00396905 in malloc_printerr (action=2, str=0x453230 "double free or corruption (!prev)", ptr=
    0x83004e0) at malloc.c:6239
#4  0x003981a3 in _int_free (av=0x46f3c0, p=0x83004d8) at malloc.c:4772
#5  0x0039b22d in *__GI___libc_free (mem=0x83004e0) at malloc.c:3738
#6  0x00386b55 in _IO_new_fclose (fp=0x83004e0) at iofclose.c:88
#7  0x08116efc in call_find_module (name=0xb7f52a54 "bla", path=['.']) at ../Python/import.c:2844
#8  0x08117011 in imp_find_module (self=<unknown at remote 0x0>, args=('bla', ['.']))
    at ../Python/import.c:2865
#9  0x081b1755 in PyCFunction_Call (func=<builtin_function_or_method at remote 0xb7f3cc3c>, arg=
    ('bla', ['.']), kw=<unknown at remote 0x0>) at ../Objects/methodobject.c:81
#10 0x080fbf03 in call_function (pp_stack=0xbffff3cc, oparg=2) at ../Python/ceval.c:3750
#11 0x080f75ac in PyEval_EvalFrameEx (f=File <string>, line 1, in <module> (), throwflag=0)
    at ../Python/ceval.c:2412
#12 0x080f9c48 in PyEval_EvalCodeEx (co=0xb7fe6da8, globals=
    {'__builtins__': <module at remote 0xb7fb50c4>, '__name__': '__main__', '__package__': None, '__doc__': None, 'imp': <module at remote 0xb7fb5964>}, locals=
    {'__builtins__': <module at remote 0xb7fb50c4>, '__name__': '__main__', '__package__': None, '__doc__': None, 'imp': <module at remote 0xb7fb5964>}, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, 
    defcount=0, closure=<unknown at remote 0x0>) at ../Python/ceval.c:3000
#13 0x080efd6b in PyEval_EvalCode (co=0xb7fe6da8, globals=
    {'__builtins__': <module at remote 0xb7fb50c4>, '__name__': '__main__', '__package__': None, '__doc__': None, 'imp': <module at remote 0xb7fb5964>}, locals=
    {'__builtins__': <module at remote 0xb7fb50c4>, '__name__': '__main__', '__package__': None, '__doc__': None, 'imp': <module at remote 0xb7fb5964>}) at ../Python/ceval.c:541
#14 0x0812376c in run_mod (mod=0x83565c0, filename=0x81ef6b1 "<string>", globals=
    {'__builtins__': <module at remote 0xb7fb50c4>, '__name__': '__main__', '__package__': None, '__doc__': None, 'imp': <module at remote 0xb7fb5964>}, locals=
    {'__builtins__': <module at remote 0xb7fb50c4>, '__name__': '__main__', '__package__': None, '__doc__': None, 'imp': <module at remote 0xb7fb5964>}, flags=0xbffff6c0, arena=0x82f5700)
    at ../Python/pythonrun.c:1339
#15 0x08123640 in PyRun_StringFlags (str=0x82e5008 "import imp; imp.find_module(\"bla\", [\".\"])\n", 
    start=257, globals=
    {'__builtins__': <module at remote 0xb7fb50c4>, '__name__': '__main__', '__package__': None, '__doc__': None, 'imp': <module at remote 0xb7fb5964>}, locals=
    {'__builtins__': <module at remote 0xb7fb50c4>, '__name__': '__main__', '__package__': None, '__doc__': None, 'imp': <module at remote 0xb7fb5964>}, flags=0xbffff6c0) at ../Python/pythonrun.c:1302
#16 0x081223e9 in PyRun_SimpleStringFlags (command=
    0x82e5008 "import imp; imp.find_module(\"bla\", [\".\"])\n", flags=0xbffff6c0)
    at ../Python/pythonrun.c:961
#17 0x0805e3f6 in Py_Main (argc=3, argv=0xbffff7b4) at ../Modules/main.c:521
#18 0x0805d51f in main (argc=3, argv=0xbffff7b4) at ../Modules/python.c:23
msg102687 - (view) Author: Shashwat Anand (l0nwlf) Date: 2010-04-09 06:50
<quote>mkdir bla.py; python -c 'import imp; imp.find_module("bla", ["."])'

This causes bpython to crash after the first input char if such a
directory exist.</quote>

I am sure you do not mean 'bpython intepretor' here.
msg102691 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-04-09 07:15
No, that is not bpython interpreter. The a crash report on "python interpreter" observed with imp module when a directory ends with .py.
msg102693 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-04-09 07:57
It looks like a duplicate of #7732.
History
Date User Action Args
2022-04-11 14:56:59adminsetgithub: 52599
2010-04-09 07:57:25floxsetstatus: open -> closed

nosy: + flox
messages: + msg102693

superseder: imp.find_module crashes Python if there exists a directory named "__init__.py"
resolution: duplicate
2010-04-09 07:15:57orsenthilsetnosy: + orsenthil
messages: + msg102691
2010-04-09 06:50:31l0nwlfsetnosy: + l0nwlf
messages: + msg102687
2010-04-09 04:12:13ezio.melottisetversions: - Python 2.5
nosy: + brett.cannon, ncoghlan

priority: high
type: crash
stage: test needed
2010-04-09 01:11:36dokocreate