Title: Segfault when loading not recompiled module
Type: crash Stage:
Components: Build, Distutils, Installation Versions: Python 3.0
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, chin, loewis, tarek
Priority: normal Keywords: needs review, patch

Created on 2009-04-11 11:08 by chin, last changed 2009-06-01 21:16 by amaury.forgeotdarc. This issue is now closed.

File name Uploaded Description Edit
ext1.c chin, 2009-04-11 11:08 simple hello module
module_create.patch amaury.forgeotdarc, 2009-04-14 20:44
Messages (4)
msg85853 - (view) Author: Leonid Vasilev (chin) Date: 2009-04-11 11:08
I compiled two versions of python(both from main trunk)

Here's what I do:
$cd /usr/local/src/Python-3.0.1/
$make && make install
$cd ~/pyext/
$python3.0 install
"run python3.0 and import ext1 -- it worked ok"
$cd /usr/local/src/Python-3.0.1
$mkdir debug
$cd debug
$./../configure --with-pydebug
Try to import a ext1, and got a Segfault

Backtrace from gdb:
(gdb) backtrace
#0  0xb7e9b1cb in strlen () from /lib/i686/cmov/
#1  0x0807c06d in PyUnicodeUCS2_FromString (u=0xffffffff <Address
0xffffffff out of bounds>) at ./../Objects/unicodeobject.c:553
#2  0x0816251a in PyModule_New (name=0xffffffff <Address 0xffffffff out
of bounds>) at ./../Objects/moduleobject.c:39
#3  0x0816282d in PyModule_Create2 (module=0xb7fd26a0,
module_api_version=1013) at ./../Objects/moduleobject.c:106
#4  0xb7fd14b8 in PyInit_ext1 () at ext1.c:40
#5  0x080cfda0 in _PyImport_LoadDynamicModule (name=0xbf9f8a17 "ext1",
pathname=0xbf9f798f "/usr/local/lib/python3.0/site-packages/",
    at ./../Python/importdl.c:57
#6  0x080cc226 in load_module (name=0xbf9f8a17 "ext1", fp=0x9a18ef8,
buf=0xbf9f798f "/usr/local/lib/python3.0/site-packages/", type=3,
    at ./../Python/import.c:1807
#7  0x080ce236 in import_submodule (mod=0x81b8d4c, subname=0xbf9f8a17
"ext1", fullname=0xbf9f8a17 "ext1") at ./../Python/import.c:2601
#8  0x080cd7b6 in load_next (mod=0x81b8d4c, altmod=0x81b8d4c,
p_name=0xbf9f9a30, buf=0xbf9f8a17 "ext1", p_buflen=0xbf9f8a10) at
#9  0x080ccbdf in import_module_level (name=0x0, globals=0xb7e10714,
locals=0xb7e10714, fromlist=0x81b8d4c, level=0) at ./../Python/import.c:2123
#10 0x080ccfc7 in PyImport_ImportModuleLevel (name=0x9a057f0 "ext1",
globals=0xb7e10714, locals=0xb7e10714, fromlist=0x81b8d4c, level=0)
    at ./../Python/import.c:2174
#11 0x0809f65f in builtin___import__ (self=0xb7df6ce4, args=0xb7df7a9c,
kwds=0x0) at ./../Python/bltinmodule.c:173
#12 0x08161e56 in PyCFunction_Call (func=0xb7df6dfc, arg=0xb7df7a9c,
kw=0x0) at ./../Objects/methodobject.c:84
#13 0x081179c1 in PyObject_Call (func=0xb7df6dfc, arg=0xb7df7a9c,
kw=0x0) at ./../Objects/abstract.c:2161
#14 0x080b1806 in PyEval_CallObjectWithKeywords (func=0xb7df6dfc,
arg=0xb7df7a9c, kw=0x0) at ./../Python/ceval.c:3313
#15 0x080ac71c in PyEval_EvalFrameEx (f=0x9a3105c, throwflag=0) at
#16 0x080b03fa in PyEval_EvalCodeEx (co=0x9983ec8, globals=0xb7e10714,
locals=0xb7e10714, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
    kwdefs=0x0, closure=0x0) at ./../Python/ceval.c:2869
#17 0x080a562b in PyEval_EvalCode (co=0x9983ec8, globals=0xb7e10714,
locals=0xb7e10714) at ./../Python/ceval.c:526
#18 0x080dcb68 in run_mod (mod=0x9a78d68, filename=0x819ff60 "<stdin>",
globals=0xb7e10714, locals=0xb7e10714, flags=0xbf9faf70, arena=0x99126d8)
    at ./../Python/pythonrun.c:1686
#19 0x080dadf1 in PyRun_InteractiveOneFlags (fp=0xb7f81420,
filename=0x819ff60 "<stdin>", flags=0xbf9faf70) at
#20 0x080da953 in PyRun_InteractiveLoopFlags (fp=0xb7f81420,
filename=0x819ff60 "<stdin>", flags=0xbf9faf70) at
#21 0x080da7ab in PyRun_AnyFileExFlags (fp=0xb7f81420,
filename=0x819ff60 "<stdin>", closeit=0, flags=0xbf9faf70) at
#22 0x080ec7a7 in Py_Main (argc=1, argv=0xb7de3028) at
#23 0x0805a75b in main (argc=1, argv=0xbf9fb0b4) at ./../Modules/python.c:70
msg85975 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-04-14 20:44
Normally, modules compiled with incompatible settings should generate a 
link-time error (like: Undefined symbol PyModule_Create).
This used to work with 2.x, but a typo in a macro broke this for 3.x.

Patch attached.
msg85981 - (view) Author: Leonid Vasilev (chin) Date: 2009-04-15 04:32
Thanks for patch, it works now:

Python compiled with --with-pydebug throws an ImportError when trying to
import modules compiled without --with-pydebug, as it should:

ImportError: /usr/local/lib/python3.0/site-packages/ undefined
symbol: PyModule_Create2
msg88679 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-06-01 21:16
Fixed with r73116
Date User Action Args
2009-06-01 21:16:53amaury.forgeotdarcsetstatus: open -> closed
resolution: fixed
messages: + msg88679
2009-04-15 04:32:34chinsetmessages: + msg85981
2009-04-14 20:44:17amaury.forgeotdarcsetfiles: + module_create.patch

nosy: + amaury.forgeotdarc
messages: + msg85975

keywords: + needs review, patch
2009-04-13 08:42:37tareksetassignee: tarek ->
2009-04-11 21:50:40loewissetnosy: + loewis
2009-04-11 11:08:41chincreate