我有一个调用 PyEnchant 的多线程 Python 应用程序。我不是 Python 专家,大部分代码来自第三方。我所做的是添加代码以从多线程应用程序调用 PyEnchant。由于我进行了更改,应用程序运行了不同的时间长度然后崩溃。我在 Ubuntu 12.04 上运行它。我收到如下错误:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffc5ffd700 (LWP 6858)]
0x00007ffff4424854 in ?? () from /usr/lib/libenchant.so.1
(gdb) backtrace
#0 0x00007ffff4424854 in ?? () from /usr/lib/libenchant.so.1
#1 0x00007ffff442517d in enchant_dict_check () from /usr/lib/libenchant.so.1
#2 0x00007ffff48a2ea4 in ffi_call_unix64 () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#3 0x00007ffff48a28c5 in ffi_call () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#4 0x00007ffff48932c2 in _ctypes_callproc () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#5 0x00007ffff4893aa2 in ?? () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#6 0x00000000004c7c76 in PyObject_Call ()
#7 0x000000000042aa4a in PyEval_EvalFrameEx ()
#8 0x000000000042abe2 in PyEval_EvalFrameEx ()
#9 0x000000000042abe2 in PyEval_EvalFrameEx ()
#10 0x00000000004317f2 in PyEval_EvalCodeEx ()
#11 0x000000000054aa40 in ?? ()
#12 0x00000000004c7c76 in PyObject_Call ()
#13 0x000000000049e9ba in ?? ()
#14 0x00000000004c7c76 in PyObject_Call ()
#15 0x00000000004c7d36 in PyEval_CallObjectWithKeywords ()
#16 0x0000000000443e3a in ?? ()
#17 0x000000000042a862 in PyEval_EvalFrameEx ()
#18 0x000000000042abe2 in PyEval_EvalFrameEx ()
#19 0x000000000042abe2 in PyEval_EvalFrameEx ()
或者
*** glibc detected *** /usr/bin/python: free(): invalid pointer: 0x00007fffd4000178 ***
(gdb) backtrace
#0 0x00007ffff68fa445 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff68fdbab in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff6937e2e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007ffff6942626 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007ffff4424861 in ?? () from /usr/lib/libenchant.so.1
#5 0x00007ffff442517d in enchant_dict_check () from /usr/lib/libenchant.so.1
#6 0x00007ffff48a2ea4 in ffi_call_unix64 () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#7 0x00007ffff48a28c5 in ffi_call () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#8 0x00007ffff48932c2 in _ctypes_callproc () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#9 0x00007ffff4893aa2 in ?? () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#10 0x00000000004c7c76 in PyObject_Call ()
#11 0x000000000042aa4a in PyEval_EvalFrameEx ()
#12 0x000000000042abe2 in PyEval_EvalFrameEx ()
#13 0x000000000042abe2 in PyEval_EvalFrameEx ()
#14 0x00000000004317f2 in PyEval_EvalCodeEx ()
#15 0x000000000054aa40 in ?? ()
#16 0x00000000004c7c76 in PyObject_Call ()
#17 0x000000000049e9ba in ?? ()
#18 0x00000000004c7c76 in PyObject_Call ()
#19 0x00000000004c7d36 in PyEval_CallObjectWithKeywords ()
#20 0x0000000000443e3a in ?? ()
#21 0x000000000042a862 in PyEval_EvalFrameEx ()
#22 0x000000000042abe2 in PyEval_EvalFrameEx ()
或者
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe57fa700 (LWP 17532)]
0x0000000000000000 in ?? ()
(gdb) backtrace
#0 0x0000000000000000 in ?? ()
#1 0x00007ffff3f5fe33 in g_hash_table_lookup () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2 0x00007ffff44245a3 in ?? () from /usr/lib/libenchant.so.1
#3 0x00007ffff442518b in enchant_dict_check () from /usr/lib/libenchant.so.1
#4 0x00007ffff48a2ea4 in ffi_call_unix64 () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#5 0x00007ffff48a28c5 in ffi_call () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#6 0x00007ffff48932c2 in _ctypes_callproc () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#7 0x00007ffff4893aa2 in ?? () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#8 0x00000000004c7c76 in PyObject_Call ()
#9 0x000000000042aa4a in PyEval_EvalFrameEx ()
#10 0x000000000042abe2 in PyEval_EvalFrameEx ()
#11 0x000000000042abe2 in PyEval_EvalFrameEx ()
#12 0x00000000004317f2 in PyEval_EvalCodeEx ()
#13 0x000000000054aa40 in ?? ()
#14 0x00000000004c7c76 in PyObject_Call ()
#15 0x000000000049e9ba in ?? ()
#16 0x00000000004c7c76 in PyObject_Call ()
#17 0x00000000004c7d36 in PyEval_CallObjectWithKeywords ()
#18 0x0000000000443e3a in ?? ()
#19 0x000000000042a862 in PyEval_EvalFrameEx ()
#20 0x000000000042abe2 in PyEval_EvalFrameEx ()
#21 0x000000000042abe2 in PyEval_EvalFrameEx ()
#22 0x000000000042abe2 in PyEval_EvalFrameEx ()
阅读我尝试过的另一篇文章
ulimit -s unlimited
以及 ulimit 的各种其他值,但它似乎没有帮助。
我已经监视了以“top”运行的应用程序,它似乎没有使用太多资源。有时它运行 5 分钟,有时 15 分钟。在这些运行期间,它处理数百个字符串并找到数百个未知单词。运行代码的机器没有已知问题,它是我的开发机器,其他一切都稳定运行。
任何人都可以阐明这些错误的含义吗?在我的 Python 代码中是否有我应该或不应该做的事情来解决它?我想这是一个内存问题(我对此知之甚少),我应该检查内存泄漏等吗?