我有一個C擴展模塊,我在CentOS上使用 distutils構建和使用。調用Python C擴展模塊時出現分段錯誤
蟒蛇setup.py build_ext --inplace
然而此刻我嘗試在64位的Ubuntu的機器我得到使用相同的(再重新編譯當然生成.so文件)調用C模塊時出現分段錯誤。
我正在使用Python 2.7。
用gdb運行它,我收到以下的跟蹤
[Switching to Thread 0x7ffff232f700 (LWP 4685)]
convertsimple (freelist=0x7ffff232c840, bufsize=256, msgbuf=0x7ffff232c8d0 "", flags=0,
p_va=0x54a812, p_format=<synthetic pointer>, arg=0x808430) at Python/getargs.c:716
716 Python/getargs.c: No such file or directory.
注相同的代碼工作正常在CentOS的64位當我編譯的擴展模塊,並使用它。
GDB BKtrace
(gdb) bt
#0 convertsimple (freelist=0x7ffff232b820, bufsize=256, msgbuf=0x7ffff232b8b0 "\250",
flags=-72515583, p_va=0x7ffff232b920, p_format=<synthetic pointer>, arg=0x808430)
at Python/getargs.c:716
#1 convertitem (arg=0x808430, [email protected]=0x7ffff232b818,
[email protected]=0x7ffff232ba08, [email protected]=0,
[email protected]=0x7ffff232b830, [email protected]=0x7ffff232b8b0 "\250",
[email protected]=256, [email protected]=0x7ffff232b820)
at Python/getargs.c:514
#2 0x00000000004c8cb2 in vgetargs1 (args=0x7fffe80475f0, format=0x7ffff2582b70 "is#i",
[email protected]=0x7ffff232ba08, [email protected]=0) at Python/getargs.c:345
#3 0x00000000004c8fc9 in PyArg_ParseTuple ([email protected]=0x7fffe80475f0,
[email protected]=0x7ffff2582b70 "is#i") at Python/getargs.c:85
#4 0x00007ffff2581dd3 in cbmsg_parse (self=<optimized out>, args=0x7fffe80475f0)
at src/cbmsgmodule_v1.c:44
#5 0x00000000004b5816 in call_function (oparg=<optimized out>, pp_stack=0x7ffff232bc30)
at Python/ceval.c:4021