jash-kothari-forks / libtorrent

Automatically exported from code.google.com/p/libtorrent
Other
0 stars 0 forks source link

Segfault loading libtorrent on OpenSuSE 12.1 #358

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This was originally reported as Deluge ticket 2144 
(http://dev.deluge-torrent.org/ticket/2144), but the Deluge developers 
suggested that it's a libtorrent problem.  The following is pasted from the 
Deluge report:

Running on OpenSuSE 12.1, building 1.3.5 from source on a 64-bit machine, I get 
a segfault when starting deluged from the command line. Based on the traceback, 
it looks like somebody is clobbering the stack in initlibtorrent, because $rip 
is invalid at crash time. Unfortunately, I don't have time right now to dig 
further.

I have attached a typescript of a brief gdb session.

(Further comment)

More info: I stepped a bit into initlibtorrent. The problem is only 4 
instructions deep, where it does:

    jmpq *0x46cdf2(%rip) # 0x2aaab08ff498

Sure enough, 0x2aaab08ff498 contains the offending address. But I don't know 
what's supposed to be there. (The vicinity of the address does look like a jump 
table of some sort, but either the addresses are relative or they haven't been 
relocated properly. But I don't know enough about Boost et al to decode 
further.)

Original issue reported on code.google.com by ge...@cs.hmc.edu on 9 Aug 2012 at 7:59

Attachments:

GoogleCodeExporter commented 9 years ago
It looks like the build of the python binding .so is simply link-incompatible 
with python. if you dump the libtorrent.so python binding (this file: 
"/usr/local/lib64/python2.7/site-packages/deluge-1.3.5-py2.7-linux-x86_64.egg/de
luge/libtorrent.so"). Does it look like what you would expect?

is it the same architecture as python itself (32bit vs. 64 bit for instance). 
As far as I can tell, the libtorrent binding code is never touched in this 
crash.

Original comment by arvid.no...@gmail.com on 9 Aug 2012 at 10:47

GoogleCodeExporter commented 9 years ago
Thanks for the hints.  I hate being so clueless, but I'm not certain
what you mean by "dump", and I don't know if it looks like what I'd
expect because I don't have sufficient knowledge about the details of
dynamic libraries to have expectations. :-(

They're both the same architecture:

bash-4.2# file /usr/bin/python2.7
/usr/bin/python2.7: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), 
dynamically linked (uses shared libs), for GNU/Linux 2.6.16, 
BuildID[sha1]=0x2159bd8ac2a26ecf3d1a20e7df7ffd42f46e5704, stripped

bash-4.2# file 
/usr/local/lib64/python2.7/site-packages/deluge-1.3.5-py2.7-linux-x86_64.egg/del
uge/libtorrent.so
/usr/local/lib64/python2.7/site-packages/deluge-1.3.5-py2.7-linux-x86_64.egg/del
uge/libtorrent.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), 
dynamically linked, BuildID[sha1]=0x145e11dd64df5c50d16618908b274ef128855a91, 
not stripped

Those both look OK to me.  A simple objdump looks OK to my uneducated eye:

bash-4.2# objdump -f 
/usr/local/lib64/python2.7/site-packages/deluge-1.3.5-py2.7-linux-x86_64.egg/del
uge/libtorrent.so

/usr/local/lib64/python2.7/site-packages/deluge-1.3.5-py2.7-linux-x86_64.egg/del
uge/libtorrent.so:     file format elf64-x86-64
architecture: i386:x86-64, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x00000000001f9c60

I'm guessing that I'm (or rather, deluge is) building libtorrent with
incorrect switches.  Eliding the repetition in the build log, the
compiles look like this:

gcc -fno-strict-aliasing -g -O2 -DNDEBUG -fmessage-length=0 -O2 -Wall 
-D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables 
-fasynchronous-unwind-tables -g -fPIC -I./libtorrent -I./libtorrent/include 
-I./libtorrent/include/libtorrent -I/usr/include/python2.7 -I/usr/include -I 
-I/usr/include/python2.7 -c ./libtorrent/src/http_stream.cpp -o 
build/temp.linux-x86_64-2.7/./libtorrent/src/http_stream.o 
-D_FILE_OFFSET_BITS=64 -DNDEBUG -DTORRENT_USE_OPENSSL=1 
-DBOOST_FILESYSTEM_VERSION=2 -O2 -Wno-missing-braces

and the link is:

gcc -pthread -shared build/temp.linux-x86_64-2.7/./libtorrent/src/http_stream.o 
... -L/usr/lib64 -L/opt/local/lib -L/usr/lib64 -lboost_filesystem-mt 
-lboost_date_time-mt -lboost_iostreams-mt -lboost_python-mt -lboost_thread-mt 
-lpthread -lssl -lz -lpython2.7 -o 
build/lib.linux-x86_64-2.7/deluge/libtorrent.so

Original comment by ge...@cs.hmc.edu on 10 Aug 2012 at 7:56