2008/08/06

WMU-6500FS - Deluge torrent (part III)



Overview

In previous part I tried to workaround the issue with uncaught exceptions (due to the GCC mis-configuration), but after the long effort (and after a discovery of a separate linker problem) I decided to rebuild the GCC compiler.
Now with the new (properly configured) compiler we are ready to finish the deluge build process and finish the installation.
In this post there are described new possibilities how to use the new version of the deluge torrent client, for me especially attractive is the "daemon" mode.

Build result

[file list]

Screenshots

Deluge daemon and GTK client both running on WMU-6500fs box
GTK and web client running on Ubuntu
GTK and web client running on Windows XP

Info sources:

[Deluge News] [Deluge FAQ]

Build sequence:
dev# cd /usr/local/src/deluge-0.9.03
dev# python setup.py clean
dev# python setup.py build
dev# python setup.py install --prefix=/mnt/C/sys/
Now, when we test the new instalation, there is another problem with exception handling:
dev# deluge
[INFO    ] 00:13:19 main:84 Deluge ui 0.9.03
...
[DEBUG   ] 00:13:23 configmanager:88 Getting config 'gtkui.conf'
can't resolve symbol '_Unwind_Resume_or_Rethrow' 4.1.2
With the deluge daemon the problem is the same:
dev# deluged
can't resolve symbol _Unwind_Resume_or_Rethrow' 4.1.2
It seems there are missing symbols for the exception unwinding. Let's look at the libtorrent dependencies:
dev# cd /usr/local/src/deluge-0.9.03
dev# ldd build/lib.linux-i686-2.5/deluge/libtorrent.so
        libboost_filesystem-gcc33-mt-1_35.so.1.35.0 => /mnt/C/sys/lib/libboost_filesystem-gcc33-mt-1_35.so.1.35.0 (0x00000000)
        libboost_date_time-gcc33-mt-1_35.so.1.35.0 => /mnt/C/sys/lib/libboost_date_time-gcc33-mt-1_35.so.1.35.0 (0x00000000)
        libboost_iostreams-gcc33-mt-1_35.so.1.35.0 => /mnt/C/sys/lib/libboost_iostreams-gcc33-mt-1_35.so.1.35.0 (0x00000000)
        libboost_python-gcc33-mt-1_35.so.1.35.0 => /mnt/C/sys/lib/libboost_python-gcc33-mt-1_35.so.1.35.0 (0x00000000)
        libboost_thread-gcc33-mt-1_35.so.1.35.0 => /mnt/C/sys/lib/libboost_thread-gcc33-mt-1_35.so.1.35.0 (0x00000000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00000000)
        libssl.so.0.9.7 => /usr/lib/libssl.so.0.9.7 (0x00000000)
        libz.so.1 => /lib/libz.so.1 (0x00000000)
        libpython2.5.so.1.0 => /usr/lib/libpython2.5.so.1.0 (0x00000000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00000000)
        libc.so.0 => /lib/libc.so.0 (0x00000000)
        libcrypto.so.0.9.7 => /usr/lib/libcrypto.so.0.9.7 (0x00000000)
        libdl.so.0 => /lib/libdl.so.0 (0x00000000)
        libutil.so.0 => /lib/libutil.so.0 (0x00000000)
        libm.so.0 => /lib/libm.so.0 (0x00000000)
        /lib/ld-uClibc.so.0 => /lib/ld-uClibc.so.0 (0x00000000)
And now when we look at the individual symbol dependencies:
dev# nm -D build/lib.linux-i686-2.5/deluge/libtorrent.so | grep Unwind
         U _Unwind_SjLj_Register
         U _Unwind_SjLj_Resume
         U _Unwind_SjLj_Unregister

dev# nm -D /mnt/C/sys/lib/libboost_filesystem-gcc33-mt-1_35.so.1.35.0 | grep Unwind
         U _Unwind_Register
         U _Unwind_Resume
         U _Unwind_Unregister
... It is clear that I forgot to rebuild the boost library with the new compiler!
Ok, so let's fix it and not forget to activate back the exceptions (comment out the define we previously added to the boost/config/user.hpp):
dev# cd ../boost_1_35_0
dev# nano boost/config/user.hpp

    //#define BOOST_NO_EXCEPTIONS
dev# ./configure --prefix=/mnt/C/sys/
dev# make
...patience...
...found 3940 targets...
...updating 9 targets...
...
...updated 9 targets...

dev# make install
...found 14676 targets...
...updating 7 targets...
...
...updated 7 targets...
Now let's go back to deluge and rebuild it:
dev# cd ../deluge-0.9.03
dev# python setup.py clean
dev# python setup.py build
...
/mnt/C/sys/lib/gcc/i386-linux-uclibc/4.1.2/../../../../i386-linux-uclibc/bin/ld: cannot find -lboost_filesystem
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
We have to update the symlinks we previously created for gcc33 version of boost libraries:
dev# cd /mnt/C/sys/lib
dev# for i in `ls ./libboost_*-gcc41-mt-1_35.so.1.35.0`; do ln -s $i ${i/%-gcc41-mt-1_35.so.1.35.0/.so}; done
`./libboost_date_time.so': File exists
...
`./libboost_wave.so': File exists
The links are already there, but we want to rewrite them:
dev# ls -l libboost_date_time.so
lrwxrwxrwx  1 root root 44 Jul 23 06:33 libboost_date_time.so -> ./libboost_date_time-gcc33-mt-1_35.so.1.35.0
dev# for i in `ls ./libboost_*-gcc41-mt-1_35.so.1.35.0`; do ln --force -s $i ${i/%-gcc41-mt-1_35.so.1.35.0/.so}; done
Now we can proceed with deluge:
dev# cd /usr/local/src/deluge-0.9.03
dev# python setup.py build 
dev# python setup.py install --prefix=/mnt/C/sys
Ok, it is now installed. When we try it we end up with already known icon issue (sed helps us to solve it):
dev# deluge
...
 line 59, in __init__
    self.dialog.set_icon(deluge.common.get_logo(32))
  File "/mnt/C/sys/lib/python2.5/site-packages/deluge-0.9.03-py2.5-linux-i686.egg/deluge/common.py", line 143, in get_logo
    size, size)
gobject.GError: Unrecognized image file format
dev# sed -i 's/deluge.svg/deluge.png/g' /mnt/C/sys/lib/python2.5/site-packages/deluge-0.9.03-py2.5-linux-i686.egg/deluge/common.py
Next run ended up with segfault:
dev# deluge
...
gtk_icon_theme_load_icon: assertion `GTK_IS_ICON_THEME (icon_theme)' failed
  self.window.show()
Segmentation fault
In order to be able to debug it, I had to deploy it to the box. But after the deployment some more problems emerged:
box# deluge
Traceback (most recent call last):
  File "/usr/bin/deluge", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 2561, in <module>
  File "/usr/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 626, in require
  File "/usr/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 524, in resolve
pkg_resources.DistributionNotFound: deluge==0.9.03
... we have to create a path to deluge egg:
box# cd /mnt/C/sys/lib/python2.5/site-packages
box# echo "./deluge-0.9.03-py2.5-linux-i686.egg" > deluge.pth
Then I noticed following wierd error:
box# deluge
...
gobject.GError: Failed to open file 

'/tmp/mnt/C/sys/lib/python2.5/site-packages/deluge-0.9.03-py2.5-linux-i686.egg/deluge/data/pixmaps/seeding16.png': No such file or directory
... do not know why, two files were untarred with a wrong name (with "0000644" postfix), quick fix:
box# mv /tmp/mnt/C/sys/lib/python2.5/site-packages/deluge-0.9.03-py2.5-linux-i686.egg/deluge/data/pixmaps/seeding16.png{0000644,}
... then it seems we successfully replicated the crash:
box# deluge
...
rning: gtk_icon_theme_load_icon: assertion `GTK_IS_ICON_THEME (icon_theme)' failed
  self.window.show()
Segmentation fault
Let's start debugging:
box# gdbserver colinux:2345 `which python` `which deluge`
... and attach with debugger remotely:
dev# gdb `which python`
...
(gdb) target remote storage:2345
(gdb) cont
Continuing.
[New Thread 1024]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024]
0x408c1572 in render_icon_name_pixbuf () from /mnt/C/sys/X11/lib/libgtk-x11-2.0.so.0
(gdb) where
#0  0x408c1572 in render_icon_name_pixbuf () from /mnt/C/sys/X11/lib/libgtk-x11-2.0.so.0
#1  0x408c1736 in find_and_render_icon_source () from /mnt/C/sys/X11/lib/libgtk-x11-2.0.so.0
#2  0x408c1992 in gtk_icon_set_render_icon () from /mnt/C/sys/X11/lib/libgtk-x11-2.0.so.0
#3  0x40a61ded in gtk_widget_render_icon () from /mnt/C/sys/X11/lib/libgtk-x11-2.0.so.0
#4  0x408e0499 in gtk_image_calc_size () from /mnt/C/sys/X11/lib/libgtk-x11-2.0.so.0
#5  0x408e061e in gtk_image_size_request () from /mnt/C/sys/X11/lib/libgtk-x11-2.0.so.0
...
Do not know why the exactly render_icon_name_pixbuf function crashed, but I noticed that I was not running the Xming server, when I started it, the problem was gone.
Another problem - missing __cxa_pure_virtual symbol:
box# deluged
/usr/bin/python: can't resolve symbol '__cxa_pure_virtual'
... was "solved" with dirty LD_PRELOAD workaround, then there was another missing symbol 'BIO_free':
box# LD_PRELOAD=/usr/lib/libstdc++.so.6 deluged
/usr/bin/python: can't resolve symbol BIO_free
... pre-loading libssl moved us forward to next missing symbol '_ZN5boost6system18get_posix_categoryEv':
box# LD_PRELOAD="/usr/lib/libstdc++.so.6 /usr/lib/libssl.so.0.9.7" deluged
/usr/bin/python: can't resolve symbol _ZN5boost6system18get_posix_categoryEv
Have no idea what exactly is going on here (and would be pleased if anybody described it to me), but as a workaround the following helped:
box# LD_PRELOAD="/usr/lib/libssl.so.0.9.7 /usr/lib/libboost_filesystem-gcc41-mt-1_35.so.1.35.0" deluged
The same pair of libraries I am pre-loading for the deluge GUI.

Setup

Finally I was able to run deluge, but yet, I forgot to create symlinks to font directories:
For details see this page.
box# mkdir /usr/share/fonts
box# ln -sn /mnt/C/sys/X11/lib/X11/fonts/OTF /usr/share/fonts/X11-OTF
box# ln -sn /mnt/C/sys/X11/lib/X11/fonts/TTF /usr/share/fonts/X11-TTF
The next thing I set up was to allow remote connections: Then on client machines - running Win XP and Ubuntu in my case - in order to be able to remotely connect to the deluge daemon running on the WMU-6500fs box - I had to disable the classic mode: ... and select storage as a default host in Connection Manager: As can be seen at following screenshot, the memory consumption is relatively high, but when I am not running web gui on the box (just deluged daemon) and am connecting to it from other computers, it is very stable and running smoothly.

4 comments:

Denier said...

Dear Filodej,

This is Aqualung from the MACSAT forums. First of all, thank you very much for the nice Deluge work.

I have lost touch lately with the world of WMU-6500FS, and I'd like to get back into configuring my box properly. I, hence, would like to ask you a few questions:

1. It looks as if they have finally released the Deluge version everybody's been waiting for--that is, the version that supports headless devices, and works in daemon mode. Did you by any chance manage to compile it for the WMU-6500FS?

2. If yes, would you care to write a short tutorial for Linux newbies as to how one can install it on their boxes?

3. Given that you seem to have a gift (and patience) for explaining, I wouldn't mind if you could write a tutorial on how to configure the box from scratch, using Joker's latest firmware. All I actually need the box to do is to run Deluge properly, hence no need for intricate explanations on how to set up NFS etc. I am perfectly happy with Airlive's Samba at this point: the only thing I don't like is the box's default BT client.

Many thanks again,

Aqualung

Unknown said...

Hi pls. help

/usr/bin/python: can't resolve symbol 'g_assertion_message_expr'

and I don`t have libstdc++.so.6 in my lib/ dir. only libstdc++.so.5.0.7

Many thanks.

filodej said...

Hi demjen,
I am not sure what the cause for g_assertion_message_expr is. You probably did not prepare all the dependencies. Unfortunately I am not at home right now and cannot look up what is the library this symbol is actually defined in. I'll look it up as soon as I can.

Ad to libstdc++.so.6 - sorry for that, I probably should have prepared some package containing system libraries (as for example JoKeR did).
As a quick solution for you - the library you mention (as well as some related ones) is present in the gcc-4.1.2-sjlj package. You can extract just libraries you need in case you do not want to use gcc for building your own. It is possible that the missing symbol relates to the lack of this library as well.

Hope this helps,
regards
Filodej

filodej said...

Hello Aqualung,
Sadly I have very little time nowadays, so sorry for such a late reply. I have some plans but all is just a matter of time (my job was much less time-consuming during the summer time than it is right now).

Answers for your questions follow:

1. I am definitely going to build the final version as well as prepare a short post describing is in a step by step fashion (however it will be probably based on a knowledge I got and described during the previous build process(es) ).

2. I am preparing a very simple packaging system (actually it is just one shell script) aiming to help potential users with the installation process. It would be definitely better to base it on the well established aptitude system, rather than create my own (primitive) system, but I had no time to study the aptitude yet (probably it would be much easier than I imagine).

3. I have no actual plans in this area, my activities so far were mainly driven by my own requirements (and my need to write things down in order to remember it). Another problem is that in some cases I am not able to distinguish between the original JoKeR's box state and my own tweaks, so in order to be able to prepare a reliable tutorial I would have to abandon my current configuration and start from scratch (at least for some time). Unfortunately I do not have time for that right now.

Sorry for such an unsatisfactory answer, I will try hard to prepare something at least for points 1. and 2. as soon as possible.

Regards,
Filodej