The dark traps of refactoring… (or, not every bug is a platform bug)

  • user warning: Table 'drupal_herzi_eu.semaphore' doesn't exist query: SELECT expire, value FROM semaphore WHERE name = 'menu_rebuild' in /var/lib/www/shared/drupal-6.16/includes/lock.inc on line 154.
  • user warning: Table 'drupal_herzi_eu.semaphore' doesn't exist query: SELECT expire, value FROM semaphore WHERE name = 'menu_rebuild' in /var/lib/www/shared/drupal-6.16/includes/lock.inc on line 154.

When I ported the GtkCTree from GQ to GtkTreeView and GtkTreeModel I started to get a really strange problem:

Gtk-ERROR **: file gtktreeview.c: line 4726 (gtk_tree_view_bin_expose): assertion failed: (node != tree->nil)
aborting...
Aborted (core dumped)

This didn't happen always but happened some times (approximately ~20% of the "expand a node" cases).

So I thought this could be a bug in GTK+ that I just triggered because I was using some funny hack on the tree (which actually is just ugly and not evil in any way). So I created a test case for a proper bug report (testcase: 293 loc vs. GQ: 28000+ loc). Unfortunately I wasn't able to reproduce this bug using the test case. So I took another look at the stack traces: my first observation about a month ago has been: this gets triggered from a main loop and not one of my functions, so it should be a GTK+ bug. This time I realized that this main loop code is actually the main loop flushing code (using gtk_events_pending() and gtk_main_iterate()) in my application. Actually called from the tree model while creating the nodes.

Outcome: if you trigger really evil bugs from main loop code, check that it's not some main loop code (eg. expose handlers of the tree view) that gets started from your code (the tree model). Evil.

Memo: Never call into the main loop from a tree model.

Trackback URL for this post:

http://web.herzi.eu/en/trackback/103

Tags for The dark traps of refactoring… (or, not every bug is a platform bug)