Hunting Leaks in GTK+ Applications

Hunting leaks in GTK+ application used to be fairly simple: you would run your application under Purify (or, later, Valgrind) and the leak reports would pretty much tell you where to go plug.

That was a long time ago. In the meantime, GTK+ has gotten more complex over its iterations with more caches, more inter-object links, and deliberately-unfreed objects. On top of that, Valgrind and Purify are not particular well suited for finding the cause of leaks: by design they will tell you the backtrace of the call that allocated memory which was never leaked. In a ref-counted world that information is often quite insufficient: the leaked widget was allocated by the gui builder — oh goodie! What you really want to know is who holds the extra ref.

Enter the gobject debugger first introduced by Danielle here. After some major internal work, it has become mature.

I used this for Gnumeric, which was already one of the strictest leak-policed applications in GTK+ land. We leaked a number of GtkTreeModel/GtkListStore objects, for example. Easily fixed. Also, when touching print code or file choosers we leaked massively: one object per printer and/or two objects per file in the current directory. A sequence of bug reports (646815, 646462, 646446, 646461, 646460, 646458, 646457, and 645483) later, GTK+ is now behaving much better. All but the last of these have been fixed. With this, we are down to leaking about 20 Gtk-related objects: the recent-documents manager, im-module objects, the default icon factory, and theme engines. Basically stuff that GTK+ does not want to release.

Please try this on your applications, especially if they are long-running. I still have to kill gnome-terminal, banshee, metacity, and gvfsd from time to time when they grow to absurd sizes. That doesn’t have to be caused by GObject leaks, but it might very well. (I know some of these samples are obsolete; I am not naive enough to believe their replacements would fare any better.)

This might be a good time to remind people that g_object_get and gtk_tree_model_get will give you a reference when you use them to retrieve GObjects. You need to unref when done. The problem is that it is not immediately clear from the g_object_get/gtk_tree_model_get call whether existing code is getting objects, so a certain knowledge of the code is needed.

OpenSUSE 11.2

I decided to give a new OpenSUSE 11.2 a spin. In hindsight, that was probably a mistake.

The new version installs a desktop-optimized kernel. The idea sounds good, but for me it does not work: named consistently causes an Oops or a kernel panic. (I haven’t otherwise had a kernel panic for many, many years!) I reverted to the so-called “default” kernel and the system seems to suffer only a loss of my confidence.

Somewhat more worrisome is that the system seems to have no bladder^Wfan control. The fan remains off until the temperature reaches crazy levels. Then the fan turns on full-blast and remains on until shutdown. In the same department, the backlight controls do not work. The tricks that worked in 11.1 no longer do. I am going to try a bios upgrade and see if things improve.

Ideas, anyone? This is a Toshiba Satellite L305-S5944. Drop me a line at mwelinder at gmail.

Update: I really don’t think 11.2 likes me:

  • Emacs’ menus are partially broken. For example, in Dired the menus for Mark/Regexp/Immediate/Subdir are all empty.
  • Valgrind is broken. I get incomplete stack traces for places with full debug info. I get complaints about unrecognized syscalls.
  • The source repository doesn’t seem to be set up right.

But, hey!, it comes with wobbly windows. What more can anyone want?

Goodbye F-Spot, Hello Picasa

I am giving up on F-Spot.

It was a really promising application, but it has never been able follow up on that great start. The worst thing is that it is sluggish. Operations that should be instant — like displaying the next image — are not, but take half a second. (Getting a new camera did not help there!) I used to think it was just my old laptop, but with a new laptop that excuse does not fly anymore.

I have now tried Picasa. It is crazy-fast! For now, I am going to use that. The biggest problem was migrating the F-Spot tags. That problem was solved with the help from a Robert Brown on Google’s help forums.

Basically, you need this script to create album files and then blow away Picasa’s database to force a regeneration.

Interwoven Alignment Preambles

Thomas, that is a fine rant, but I look in vain for the answer to the question of whether you could get work done after spending 15 minutes learning git instead of cursing it for not having the same command line arguments as cvs. I am sure that with counseling you could get over typing “–help” instead of “-h”.

One of my favourite error messages in from TeX. Stuff this into TeX and look in the log:


It will tell you that “Interwoven alignment preambles are not allowed”. A bit cryptic, you might say, but TeX comes with a manual, i.e., The TeXbook which helpfully explains

If you have been so devious as to get this message, you will understand it, and you deserve no sympathy.

The Gtk+ File Chooser Dialog

Whenever I update my OpenSuSE installation, the Gtk+ File Chooser Dialog get worse. This is how it looks for me on OpenSuSE 11.1 when used from Gnumeric. It looks more or less the same from Gedit and Mozilla.

Gtk+ File Chooser Dialog
Gtk+ File Chooser Dialog

I hope I am not breaking new ground when I claim that the purpose of the file chooser is to help the user choose a file. How is that going to happen when the area used for files is less than the size of one button?

I really hope other people are seeing something sane, but this is with a vanilla install, I think. (Note: I mention OpenSuSE 11.1 for reference, not as an assignment of blame.)

OpenSuSE 11.1 First Impressions

I have been running OpenSuSE 11.1 for about a week now. My first impression is that it feels nicer, but that there are severe setbacks that slipped through QA.

  • It seems to boot faster than 11.0. I was never really bothered by the boot time, so I do not have concrete measurements.
  • The 30000-wakeups-per-second bug is gone! Yeah!
  • It’s still Beagle-infested, so everything is dog slow out of the box. I am having a hard time thinking anyone with a laptop really likes to have Beagle on it. Oh well, I simply use rpm to erase anything related to beagle and install Gnu’s locate.
  • Printing on my hplj-3330 works, but I had to force it to use a non-default driver. That’s not a big deal for me, but it fails the Grandma-test.
  • I plug in my camera. I am asked if I want to import photos to f-spot. I do. f-spot then starts but tells me “Could not lock device”. A bit of poking around reveals that gvfsd-gphoto2 needs to be killed for f-spot to work.
  • The Cairo shipped, 1.8.0, is old and has a badly-broken pdf backend. This evidently is known in Cairo land. I wouldn’t expect anything that prints using gtk+ to work right. Also, since Gnumeric’s tests fail, I need to work around that before I can do releases again.

Licensed to Drive

Right now I seem to be licensed to drive. So much so, in fact, that I have six driver’s licenses:

  • my expiring license
  • an interim license I got when I renewed
  • a new license with a mistake in the address
  • a new interim license
  • a new and correct license
  • my trusty old Danish license, good for another three decades

Time to send most of those through the shredder…


It is a wild ride on Wall Street these days.  In case you missed it, the United States have taken over control of certain large financial institutions: Bear Stearns and Co., Freddie Mac, Fannie Mae, and now AIG.  These institutions have been nationalized.

Now go look at news for the word “nationalized”. You will find it for AFP [France] and The Globe and Mail [Canada], for example. You will not find it for Barrons [USA] or Reuters [USA].

It is clearly a hard word for USA based media to use when discussing things that happen the United States. The same media would use that same word in a jiffy if they were describing events in, say, France. (If you go a little further down the list of Google hits, you will find the word, of course. Seeking Alpha has it, for example, although it seems more like a provocation of its readership.)

The take-home message is that US news is heavily censored — not Government censored, but self-censored. Another notable subject that gets this treatment is news from the Middle East.

Suggestion: make sure you do not get all your news from US sources.

Beijing, August 2008

Security at this year’s Olympic Games in Beijing was impressive, at least to my five-year old son, _L_: one of the first things he built with his limited supply of Lego was a security checkpoint. I am less impressed.

It started in the airport. They wanted to scan all carry-on luggage upon arrival. I have no idea what they were looking for, but the scanning took place after people collected their checked luggage and had had a long time to move things back and forth thus making the scan effectively optional and thus pointless.

All subway entrances and all sporting venues had checks too, so authorities must have hired and trained thousands of new security people. All these people have no real experience and are constrained by having to maintain the flow of people uninterrupted. Just like when TSA was created, that makes for lousy security.

For example, when entering the venue for the US-China basketball game — where the US President was expected to attend — I arrive with my bag and camera. The bag goes into a scanner and gets hand-checked afterwards. Apart from a lot of fuss over an epipen, nothing happens. My camera comes with me through the metal detector which, of course, beeps. I get hand scanned. In other words, I just walked through with three pounds of unscanned equipment that looks like a camera! (It happens to be a camera, but how could they know?) That same equipment I later pointed at George and got a few pictures of him looking rather silly. Using the same tickets I could have walked through several times, so the size of a camera is not a limitation.

At another venue I accidentally brought a bottle of water with me. As you may know, water is a substance that is dangerous at sporting events, but not in subways. When found at a security checkpoint for a sporting venue it will be confiscated, but as a side effect, the security officer who found it will be so happy with himself that nothing else you carry will be checked. That is humanly understandable and shows that checking for liquids in the first place probably lowers the level of security. There are simply too many false positives, i.e., cases where harmless liquids are detected. Think of that the next time you wait in line at the airport.

Also, I have noticed — both in Beijing and in airports around the world — that when I put my camera equipment into my backpack, the backpack gets hand searched. I am fairly certain that it is because the operator of the scanner just sees a pile of stuff that he cannot identify, so a hand check is in order. The backpack I use is nothing special, but happens to have a lot of compartments. Generally, when the backpack is searched they miss half the compartments unless I feel like telling them.

This is all from passive observation while minding my own business. I am not trying to probe, let alone evade, security anywhere.

Conclusion: since stuff is not blowing up left and right, either the bad guys (a) are not trying; (b) are not thinking like I do; or (c) get caught or scared off by less visible parts of the security apparatus.