问题描述
我尝试在Arch Linux上安装和使用,并使用Python 2.7 .3。
I am trying to install and use dolfin on Arch Linux, with Python 2.7.3.
什么是找出导致分段
故障的最好方法?
What is the best way to find out what is causing segmentationfaults such as these?
$ python2 -c "import dolfin; print dolfin.__version__"
[3] 6491 segmentation fault (core dumped) python2 -c "import dolfin; print
dolfin.__version__"
我试过通过gdb检查核心文件:
I have tried inspecting the core file through gdb:
$ sudo systemd-coredumpctl gdb 6491
但是它们总是被截断:
Reading symbols from /usr/bin/python2.7...(no debugging symbols
found)...done.
BFD: Warning: /var/tmp/coredump-wSi8DV is truncated: expected
core file size >= 39694336, found: 25165824.
warning: core file may not match specified executable file.
[New LWP 7056]
Cannot access memory at address 0x7fe70be0d148
Cannot access memory at address 0x7fe70be0d140
我已经尝试在命令之间添加'print'语句,并且
跟踪到这个load_module行的问题,它加载了一个由swig构建的
模块:
I have tried adding 'print' statements between commands and havetracked the problem down to this load_module line, which loads amodule that has been built by swig:
fp, pathname, description = imp.find_module('_common', [dirname(__file__)])
print "_mod = imp.load_module('_common', \n\tfp=%s, \n\tpathname=%s, \n\tdescription=%s)" % ( fp, pathname, description)
_mod = imp.load_module('_common', fp, pathname, description)
print'行打印以下内容,显示正确:
and that 'print' line prints the following, which looks correct:
_mod = imp.load_module('_common',
fp=<open file '_common.so', mode 'rb' at 0x282d150>,
pathname=_common.so,
description=('.so', 'rb', 3))
[1] 9039 segmentation fault (core dumped) python2 -c "import dolfin; print dolfin.__version__"
我已经尝试在启动模块时添加sys.settrace获得更多
信息,但是不会发生。
I have tried adding sys.settrace at the start the module get moreinformation but that doesn't happen.
所以,我检查共享库的链接尝试
load:
So, I inspect the linkage of the shared library it is trying toload:
$ ldd _common.so
libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f52fe960000)
libavformat.so.54 => /lib64/libavformat.so.54 (0x00007f52fe61d000)
libavcodec.so.54 => /lib64/libavcodec.so.54 (0x00007f52fd6bb000)
libavutil.so.51 => /lib64/libavutil.so.51 (0x00007f52fd48d000)
libswscale.so.2 => /lib64/libswscale.so.2 (0x00007f52fd240000)
libvtkImaging.so.5.10 => /usr/lib/vtk-5.10/libvtkImaging.so.5.10 (0x00007f52fcb6e000)
libvtkftgl.so.5.10 => /usr/lib/vtk-5.10/libvtkftgl.so.5.10 (0x00007f52fc960000)
libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f52fc6c1000)
libQtGui.so.4 => /lib64/libQtGui.so.4 (0x00007f52fba1d000)
libQtCore.so.4 => /lib64/libQtCore.so.4 (0x00007f52fb546000)
libGL.so.1 => /lib64/libGL.so.1 (0x00007f52fb223000)
libXt.so.6 => /lib64/libXt.so.6 (0x00007f52fafbc000)
libvtkParallel.so.5.10 => /usr/lib/vtk-5.10/libvtkParallel.so.5.10 (0x00007f52faabd000)
libvtkexoIIc.so.5.10 => /usr/lib/vtk-5.10/libvtkexoIIc.so.5.10 (0x00007f52fa877000)
libvtkVolumeRendering.so.5.10 => /usr/lib/vtk-5.10/libvtkVolumeRendering.so.5.10 (0x00007f52f9fdf000)
libQtWebKit.so.4 => /lib64/libQtWebKit.so.4 (0x00007f52f81f9000)
libQtSql.so.4 => /lib64/libQtSql.so.4 (0x00007f52f7fb9000)
libQtNetwork.so.4 => /lib64/libQtNetwork.so.4 (0x00007f52f7c81000)
libvtkViews.so.5.10 => /usr/lib/vtk-5.10/libvtkViews.so.5.10 (0x00007f52f7993000)
libvtkInfovis.so.5.10 => /usr/lib/vtk-5.10/libvtkInfovis.so.5.10 (0x00007f52f7357000)
libpci.so.3 => /usr/lib/libpci.so.3 (0x00007f52f714b000)
libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007f52f6f2b000)
libcblas.so => /usr/lib/libcblas.so (0x00007f52f6d0a000)
libssl.so.1.0.0 => /lib64/libssl.so.1.0.0 (0x00007f52f6a9f000)
libcrypto.so.1.0.0 => /lib64/libcrypto.so.1.0.0 (0x00007f52f6696000)
libhdf5_hl.so.7.4.0 => /lib64/libhdf5_hl.so.7.4.0 (0x00007f52f6465000)
librtmp.so.0 => /lib64/librtmp.so.0 (0x00007f52f6249000)
libva.so.1 => /lib64/libva.so.1 (0x00007f52f6031000)
libxvidcore.so.4 => /lib64/libxvidcore.so.4 (0x00007f52f5d19000)
libx264.so.128 => /lib64/libx264.so.128 (0x00007f52f59ca000)
libvpx.so.1 => /lib64/libvpx.so.1 (0x00007f52f5729000)
libvorbisenc.so.2 => /lib64/libvorbisenc.so.2 (0x00007f52f525a000)
libvorbis.so.0 => /lib64/libvorbis.so.0 (0x00007f52f502d000)
libtheoraenc.so.1 => /lib64/libtheoraenc.so.1 (0x00007f52f4def000)
libtheoradec.so.1 => /lib64/libtheoradec.so.1 (0x00007f52f4bd4000)
libspeex.so.1 => /lib64/libspeex.so.1 (0x00007f52f49bb000)
libschroedinger-1.0.so.0 => /lib64/libschroedinger-1.0.so.0 (0x00007f52f46ef000)
libopenjpeg.so.1 => /lib64/libopenjpeg.so.1 (0x00007f52f44c7000)
libopencore-amrwb.so.0 => /lib64/libopencore-amrwb.so.0 (0x00007f52f42b3000)
libopencore-amrnb.so.0 => /lib64/libopencore-amrnb.so.0 (0x00007f52f4088000)
libmp3lame.so.0 => /lib64/libmp3lame.so.0 (0x00007f52f3e11000)
libgsm.so.1 => /lib64/libgsm.so.1 (0x00007f52f3c06000)
libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f52f390f000)
libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00007f52f36c1000)
libSM.so.6 => /lib64/libSM.so.6 (0x00007f52f34b9000)
libICE.so.6 => /lib64/libICE.so.6 (0x00007f52f329c000)
libXrender.so.1 => /lib64/libXrender.so.1 (0x00007f52f3091000)
libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f52f2e57000)
libXext.so.6 => /lib64/libXext.so.6 (0x00007f52f2c43000)
libnvidia-tls.so.310.19 => /lib64/libnvidia-tls.so.310.19 (0x00007f52f2a40000)
libnvidia-glcore.so.310.19 => /lib64/libnvidia-glcore.so.310.19 (0x00007f52f054d000)
libVPIC.so.5.10 => /usr/lib/vtk-5.10/libVPIC.so.5.10 (0x00007f52f0328000)
libCosmo.so.5.10 => /usr/lib/vtk-5.10/libCosmo.so.5.10 (0x00007f52f00e0000)
libsqlite3.so.0 => /lib64/libsqlite3.so.0 (0x00007f52efe33000)
libgstapp-0.10.so.0 => /lib64/libgstapp-0.10.so.0 (0x00007f52efc27000)
libgstinterfaces-0.10.so.0 => /lib64/libgstinterfaces-0.10.so.0 (0x00007f52efa14000)
libgstpbutils-0.10.so.0 => /lib64/libgstpbutils-0.10.so.0 (0x00007f52ef7f0000)
libgstvideo-0.10.so.0 => /lib64/libgstvideo-0.10.so.0 (0x00007f52ef5d4000)
libgstbase-0.10.so.0 => /lib64/libgstbase-0.10.so.0 (0x00007f52ef37f000)
libgstreamer-0.10.so.0 => /lib64/libgstreamer-0.10.so.0 (0x00007f52ef096000)
libvtkalglib.so.5.10 => /usr/lib/vtk-5.10/libvtkalglib.so.5.10 (0x00007f52eee75000)
libresolv.so.2 => /usr/lib/libresolv.so.2 (0x00007f52eec5e000)
libXau.so.6 => /usr/lib/libXau.so.6 (0x00007f52eea5a000)
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007f52ee853000)
libogg.so.0 => /lib64/libogg.so.0 (0x00007f52ee64d000)
liborc-0.4.so.0 => /lib64/liborc-0.4.so.0 (0x00007f52ee3d1000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f52ee16e000)
libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00007f52edf6b000)
libffi.so.6 => /lib64/libffi.so.6 (0x00007f52edd63000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f52edb5e000)
libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007f52ed959000)
我已读过segfault可能由一个共享库
与一个库建立链接(或链接?)一个
不同版本的另一个库,但如何找到哪一个
造成麻烦?非常感谢。
I have read that the segfault may be caused by a shared librarybeing linked with a library that was built with (or is linked with?) adifferent version of another library but how can I find out which one(s)cause the trouble? Thanks.
更新
如果我使用ltrace启动Python解释器工作(这以前会导致上述segfault):
If I start the Python interpreter with ltrace then it works (this would have previously caused the segfault as above):
$ ltrace python2
__libc_start_main(0x400710, 1, 0x7fff640c6f38, 0x400810 <unfinished ...>
Py_Main(1, 0x7fff640c6f38, 0x7fff640c6f48, 0x400710Python 2.7.3 (default, Dec 12 2012,07:12:24)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from dolfin import *
>>>
为什么ltrace运行时没有segfault?
Why is there no segfault when run by ltrace?
更新2
通过CMake配置-DCMAKE_BUILD_TYPE =调试仍然允许优化标志-O
Turns out configuring via CMake with -DCMAKE_BUILD_TYPE=Debug still allows the optimisation flag '-O' to be passed to g++. I'll try rebuilding with debug symbols (flag '-g') and see how that goes.
更新3
使用-g标志编译没有区别。
Compiling with the -g flag makes no difference.
更新4
Update 4
直接从gdb运行不会暴露分段错误(可能是使用某种形式的ltrace,如上所述):
Running directly from gdb does not expose the segmentation fault (presumably it uses some form of ltrace, as above):
$ gdb --args python2 -c "import dolfin; print dolfin.__version__"
GNU gdb (GDB) 7.5.1
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/python2...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/bin/python2 -c import\ dolfin\;\ print\ dolfin.__version__
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Traceback (most recent call last):
File "/usr/share/gdb/auto-load/usr/lib/libgobject-2.0.so.0.3400.3-gdb.py", line 9, in <module>
from gobject import register
File "/usr/share/glib-2.0/gdb/gobject.py", line 3, in <module>
import gdb.backtrace
ImportError: No module named backtrace
1.0.0+
[Inferior 1 (process 8008) exited normally]
(gdb)
推荐答案
在实时进程上使用GDB:
Use GDB on the live process instead:
gdb --args python2 -c "import dolfin; print dolfin.__version__"
(gdb) run
这篇关于如何调查imponload_module上的python2 segfault的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!