Bugs that really bite

It’s that part of the release cycle again: time to fix up all the bugs that, through negligence or incompetence, I didn’t fix back when they were filed. Two nights ago this process got me to bug 164986. Gnobots was crashing, nothing unusual there, except this was GNOME 2.8 and the usual suspects are all pre-2.6. It was also on an Ubuntu live CD.

The nice thing about a bug on a live CD distribution is that you don’t have to have that particular distro installed to check it out. So out comes the old laptop and a shiny new Ubuntu live CD (Warty). The bad thing about a live CD distribution is that when you do reproduce the bug there is virtually no debugging information. So I could reproduce the bug, I could tell which function it was in and, after brushing up my knowledge of x86 assembler and the ABI, I was even able to say what line and what pointer was NULL when it shouldn’t have been. Unfortunately finding out why it was NULL without debugging symbols is next to impossible.

Next step: compile a debugging version of gnobots on my other x86 machine and throw that and the source files on a memory stick. So now we’re getting somewhere, it quickly becomes apparent that gnobots isn’t finding any graphics files. The code to do this in gnobots does a two-pass scan of the graphics directory. The first is to determine how many likely files there are (and allocate enough memory), the second is to try the likely files and see if they really are graphics files. Tracing through this reveals that the first scan works correctly. Then the code does a g_dir_rewind and tries again. This time it gets nothing. g_dir_read_name instantly returns NULL. Huh?

Try this perl script on an Ubuntu live CD anywhere in /usr:

#!/usr/bin/perl

opendir DIR, ".";
print join(", ",readdir(DIR)), "\n";
rewinddir(DIR);
print join(", ",readdir(DIR)), "\n";
closedir(DIR);

It only prints one copy of the directory. It works fine in /home or anywhere on a normal install (Ubuntu too) and prints two copies. But it only prints one copy in the root directory or anywhere up /usr on the Warty Live CD. At this point I added code to gnobots to be a bit more resilient in the face of missing files then I closed the bug as NOTGNOME.

rewinddir is one of those functions that doesn’t admit the possibility it might fail. It doesn’t return anything, not even an error. Very strange.


Posted

in

by

Tags: