問題描述
Python ‑ 程序收到信號 SIGSEGV,分段錯誤 (Python ‑ Program received signal SIGSEGV, Segmentation fault)
我正在為我的學位論文準備一個 Python 代碼。我知道它可以工作...但不能在我的電腦上工作!
我使用的是 Ubuntu 14.04,首先我收到此錯誤:
分段錯誤(核心轉儲)
我嘗試啟動
gbd python (gbd) run MainLogic.py
結果如下:< /p>
Starting program: /usr/bin/python MainLogic.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64‑linux‑gnu/libthread_db.so.1".
Traceback (most recent call last):
File "/usr/share/gdb/auto‑load/usr/lib/x86_64‑linux‑gnu/libstdc++.so.6.0.19‑gdb.py", line 63, in <module>
from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'
[New Thread 0x7fffe13a9700 (LWP 10347)]
[New Thread 0x7fffda0a4700 (LWP 10349)]
[New Thread 0x7fffcfc29700 (LWP 10350)]
[New Thread 0x7fffcf428700 (LWP 10351)]
[New Thread 0x7fffcec27700 (LWP 10352)]
[New Thread 0x7fffce426700 (LWP 10353)]
[New Thread 0x7fffcdc25700 (LWP 10354)]
[New Thread 0x7fffcd424700 (LWP 10355)]
[New Thread 0x7fffccc23700 (LWP 10356)]
[New Thread 0x7fffb7fff700 (LWP 10357)]
Program received signal SIGSEGV, Segmentation fault.
0x00007fffd1f0f379 in convert_to_IplImage (dst=<synthetic pointer>,
o=<numpy.ndarray at remote 0x2169870>, o@entry=<? at remote 0x21672d0>)
at main.cpp:255
255 if (PyString_Check(ipl‑>data)) {
在我為回溯啟動“bt”命令後:
` 0x00007fffd1f0f379 in convert_to_IplImage (dst=<synthetic pointer>,
o=<numpy.ndarray at remote 0x2169870>, o@entry=<? at remote 0x21672d0>)
at main.cpp:255
SetCvImage (o=o@entry=<numpy.ndarray at remote 0x2169870>,api=0x21672d0)
at main.cpp:285
0x00007fffd1ec11c0 in _wrap_SetCvImage (args=<optimized out>)
at tesseract_wrap.cpp:158558
0x000000000049968d in call_function (oparg=<optimized out>,
pp_stack=0x7fffffffd210) at ../Python/ceval.c:4020
PyEval_EvalFrameEx (
f=f@entry=Frame 0xa04db0, for file /home/mypc/Model/image.py, line 404, in Methods_Text_Recognition_Based_Analysis_cc (self=<Image(max_tink_wall=0, numberDoors=0, image_run_pixel=None, file_name='13.png', list_door=[], labels=<numpy.ndarray at remote 0x14f9e90>, height=717, image_rect=None, graph_wall=<Graph(_nodes=[], _indices={}) at remote 0x7fffd23cef10>, color_image=<numpy.ndarray at remote 0x14db170>, dic_scale={}, list_cc=[<CC(numPixel=29, list_obl=[], list_rect=[], y_min=1, list_print_obl=[], image=<numpy.ndarray at remote 0xebaab0>, y_max=17, height=17, width=6, x_max=183, x_min=178, image_dist_tran=<numpy.ndarray at remote 0x1abb480>, id=1) at remote 0x7fffd0204cf8>, <CC(numPixel=78, list_obl=[], list_rect=[], y_min=1, list_print_obl=[], image=<numpy.ndarray at remote 0x1ab0940>, y_max=17, height=17, width=14, x_max=252, x_min=239, image_dist_tran=<numpy.ndarray at remote 0x1abb580>, id=2) at remote 0x7fffd0204dd0>, <CC(numPixel=95, list_obl=[], list_rect=[], y_min=1, list_print_..`
也許我的包和我的 Ubuntu 設置有問題,因為在其他電腦上代碼可以正常工作。如何解決此分段錯誤?
參考解法
方法 1:
Try updating to the latest gcc version. It should be fixed starting from somewhere in 4.8.2 or 4.8.3. You could also try updating to gcc 5.*.
If neither of those don't work, you could try the hackish way of patching /libstdc++‑v3/python/hook.in, as described here.
(by Frank Zappa、tambre)