A Recap of Fixing Bug ID 680484

Recently I have fixed the bug 680484 and learned a lot from the process. Therefore I think it deserves a blog post to share my story. The bug 680484 is about a crash when running the program gupnp-dlna-info to dump the input media file’s metadata with -v option. This crash only happens to gupnp-dlna-info linked against gstreamer-1.0. Gstreamer is a comprehensive multimedia processing library. gupnp-dlna, and many other GNOME multimedia packages, depends on it to deal with media files. Nowadays Gstreamer is under the flux from 0.10 to 1.0 (or 0.11) and many GNOME programs are busy with migrating to the Gstreamer-1.0 APIs.

A good introduction to gstreamer-1.0 can be found here. The link also provides the PPA links to install 1.0 on Precise. However I found that the APIs in this PPA slightly fall behind the head of the git. (Update: as of today, Aug 11, 2012, the PPA version is good) So I would recommend to use JhBuild to install the master version of Gstreamer by running jhbuild build gstreamer-master. You probably also need to build gst-plugins-good-master, gst-plugins-bad-master and gst-plugins-poor-master to install the necessary plugins.

To fix the bug 680484 I first verified gupnp-dlna-info had linked to the correct version of gstreamer.

[riko@localhost] tools $ ./gupnp-dlna-info --gst-version
GStreamer Core Library version

Now I reproduced the crash by issuing the command like this

[riko@localhost] tools $ ./gupnp-dlna-info ../../../gupnp-dlna-media/strict/audio/NiN_Ghosts_IV_34.mp3 -v

Profile Name: (null)
Profile MIME: (null)

  audio: audio/mpeg, mpegversion=(int)1, mpegaudioversion=(int)1, layer=(int)3, rate=(int)44100,
  channels=(int)2, parsed=(boolean)true
  Segmentation fault

To make the debugging easier I compiled the gupnp-dlna-info with shared build disabled and ‘-g’ flags to CFLAGS

[riko@localhost] gupnp-dlna $ ../../gupnp-dlna/configure --enable-shared=no CFLAGS='-g'

Next I used cgdb to load the program

cgdb --args ./gupnp-dlna-info ../../../gupnp-dlna-media/strict/audio/NiN_Ghosts_II_12_lo.mp3 -v 

In cgdb debugging window I ran the program to make it crash

Now use the command backtrace or bt to retrospect the flow of function calls.

By analyzing the function call history I decided to move the history backwards 4 steps and found a suspicious call.

After referring to the gstreamer-0.10 to 1.0 migration guide, I figured out that the line gst_structure_to_string ((GstStructure *) taglist) was deprecated and I should use gst_tag_list_to_string (taglist) instead. So I verified that in gdb and it seemed to work.

It turned out that was the reason for the crash. Fixed it and the crash was gone.


2 thoughts on “A Recap of Fixing Bug ID 680484

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s