Skip to main content

Debugging GNOME GThumb

I have been using the GNOME image viewer GThumb on my Debian system for a long time. But only now I started looking into it some more because of a bug that has become more annoying with the pictures taken by our newest smart phones.

GNOME Logo

As nobody reacted to the bug report so far I thought I might take a look myself. Cloning the gitlab repository is a no-brainer and after installing the required dependencies, latest head of tree also builds nicely. Because of the plug-in architecture, the binary is not easily started from the build directory and so I installed it to /usr/local/bin just like README.md says.

Starting it under gdb I can start looking into why comments get populated all by themselves. Unfortunately, the GLib data structures are not properly decoded by gdb as can be seen in this short transcript:

(gdb) p *settings
$2 = {parent_instance = {g_type_instance = {Python Exception <class 'gdb.error'> No type named TypeNode.:
g_class = }, ref_count = 1, qdata = 0x7fffdc0019f0},
  priv = 0x555555f16d40}
(gdb)

Solving this on Debian Buster was not hard, but as I tend to forget the details I decided to turn my notes into this short blog post.

It turns out that TypeNode is an internal symbol of GLib and so we need to install the debug symbols of glib. But let’s take one step after the other.

Debian carries the debug packages in a separate package repository. Instead of editing /etc/apt/sources.list directly, it is usually more convenient to put entries into separate files in /etc/apt/sources.list.d. After the new addition we have to update the package information:

root@krikkit:~# cd /etc/apt/sources.list.d/
root@krikkit:/etc/apt/sources.list.d# echo "deb http://deb.debian.org/debian-debug buster-debug main contrib non-free" > buster-debug.list
root@krikkit:/etc/apt/sources.list.d# cat buster-debug.list
deb http://deb.debian.org/debian-debug buster-debug main contrib non-free
root@krikkit:/etc/apt/sources.list.d# apt update
[...]
Reading package lists... Done
Building dependency tree
Reading state information... Done
root@krikkit:/etc/apt/sources.list.d#

To find the required package, we can use the helper tool find-dbgsym-packages which itself is contained in the debian-goodies package:

root@krikkit:/etc/apt/sources.list.d# apt install debian-goodies
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  konqueror libgnome2-bin
The following NEW packages will be installed:
  debian-goodies
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 83.5 kB of archives.
After this operation, 222 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 debian-goodies all 0.84 [83.5 kB]
Fetched 83.5 kB in 0s (879 kB/s)
Selecting previously unselected package debian-goodies.
(Reading database ... 331925 files and directories currently installed.)
Preparing to unpack .../debian-goodies_0.84_all.deb ...
Unpacking debian-goodies (0.84) ...
Setting up debian-goodies (0.84) ...
Processing triggers for man-db (2.8.5-2) ...
root@krikkit:/etc/apt/sources.list.d#

With that in place, we can check which symbol packages are relevant for our gthumb binary:

dzu@krikkit:~$ find-dbgsym-packages /usr/local/bin/gthumb
dpkg-query: no path found matching pattern /lib/x86_64-linux-gnu/libXext.so.6
W: Cannot find debug package for /lib/x86_64-linux-gnu/libXext.so.6 (2fcae7c9cf1b5ba62085611c360601b428ba24b9)
dpkg-query: no path found matching pattern /lib/x86_64-linux-gnu/libXcomposite.so.1
W: Cannot find debug package for /lib/x86_64-linux-gnu/libXcomposite.so.1 (fd60c2c65acf6eaa3f92c2b9a12899e3ead42141)
dpkg-query: no path found matching pattern /lib/x86_64-linux-gnu/libXau.so.6
W: Cannot find debug package for /lib/x86_64-linux-gnu/libXau.so.6 (f48f35ab49693e957bf0b776a3669a8fc7d226e2)
libatk-bridge2.0-0-dbgsym libatk1.0-0-dbgsym libatspi2.0-0-dbgsym libblkid1-dbgsym libbsd0-dbgsym libcairo-gobject2-dbgsym libcairo2-dbgsym libdatrie1-dbgsym libdbus-1-3-dbgsym libepoxy0-dbgsym libexpat1-dbgsym libffi6-dbg libfontconfig1-dbgsym libfreetype6-dbgsym libfribidi0-dbgsym libgcrypt20-dbgsym libgdk-pixbuf2.0-0-dbgsym libglib2.0-0-dbgsym libgpg-error0-dbgsym libgraphite2-3-dbgsym libgtk-3-0-dbgsym libharfbuzz0b-dbgsym liblcms2-2-dbgsym liblz4-1-dbgsym liblzma5-dbgsym libmount1-dbgsym libpango-1.0-0-dbgsym libpangocairo-1.0-0-dbgsym libpangoft2-1.0-0-dbgsym libpcre3-dbg libpixman-1-0-dbgsym libpng16-16-dbgsym libselinux1-dbgsym libsystemd0-dbgsym libthai0-dbgsym libuuid1-dbgsym libwayland-client0-dbgsym libwayland-cursor0-dbgsym libwayland-egl1-dbgsym libx11-6-dbgsym libxcb-render0-dbgsym libxcb-shm0-dbgsym libxcb1-dbgsym libxcursor1-dbgsym libxdamage1-dbgsym libxdmcp6-dbg libxfixes3-dbgsym libxi6-dbgsym libxinerama1-dbgsym libxkbcommon0-dbgsym libxrandr2-dbgsym libxrender1-dbgsym zlib1g-dbg
dzu@krikkit:~$

Currently I really only care about the basic GLib symbols, so let’s install only that package:

dzu@krikkit:~$ sudo apt install libglib2.0-0-dbgsym
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  libglib2.0-0-dbgsym
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 4382 kB of archives.
After this operation, 5054 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian-debug buster-debug/main amd64 libglib2.0-0-dbgsym amd64 2.58.3-2+deb10u2 [4382 kB]
Fetched 4382 kB in 0s (9951 kB/s)
Selecting previously unselected package libglib2.0-0-dbgsym:amd64.
(Reading database ... 331974 files and directories currently installed.)
Preparing to unpack .../libglib2.0-0-dbgsym_2.58.3-2+deb10u2_amd64.deb ...
Unpacking libglib2.0-0-dbgsym:amd64 (2.58.3-2+deb10u2) ...
Setting up libglib2.0-0-dbgsym:amd64 (2.58.3-2+deb10u2) ...
dzu@krikkit:~$

With this in place, let’s try gdb again:

dzu@krikkit:~$ gdb /usr/local/bin/gthumb
GNU gdb (Debian 8.2.1-2+b3) 8.2.1
Copyright (C) 2018 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-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/bin/gthumb...done.
(gdb) b comments__read_metadata_ready_cb
Function "comments__read_metadata_ready_cb" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (comments__read_metadata_ready_cb) pending.
(gdb) r
Starting program: /usr/local/bin/gthumb
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff4f19700 (LWP 22723)]
[New Thread 0x7fffeffff700 (LWP 22724)]
[New Thread 0x7fffef7fe700 (LWP 22726)]
[New Thread 0x7fffe781b700 (LWP 22727)]
[Switching to Thread 0x7fffe781b700 (LWP 22727)]

Thread 5 "pool" hit Breakpoint 1, comments__read_metadata_ready_cb (file_list=0x5555558cac40 = {...},
    attributes=0x555555e84c70 "*") at ../extensions/comments/main.c:92
92              settings = g_settings_new (GTHUMB_GENERAL_SCHEMA);
(gdb) n
93              store_metadata_in_files = g_settings_get_boolean (settings, PREF_GENERAL_STORE_METADATA_IN_FILES);
(gdb) p *settings
$1 = {parent_instance = {g_type_instance = {g_class = 0x5555557da250 [g_type: GSettings]},
    ref_count = 1, qdata = 0x7fffdc0257e0}, priv = 0x555555e9c540}
(gdb)

Just like expected, the "No type named TypeNode" error is gone. So at least I can start looking for the real bug now. Stay tuned.

Comments

Comments powered by Disqus