After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 342578 - Procedure Browser (PDB) crashes after refreshing Script-Fu
Procedure Browser (PDB) crashes after refreshing Script-Fu
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
git master
Other All
: Normal normal
: 2.4
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2006-05-22 14:02 UTC by Raphaël Quinet
Modified: 2006-05-24 10:55 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Raphaël Quinet 2006-05-22 14:02:27 UTC
In current CVS, refreshing the Script-Fu scripts causes the PDB browser to
crash the next time it is invoked.  If the PDB browser is already open, then
it may still work for a while but sooner or later it will crash due to memory
corruption (with a gimp error dialog containing corrupted strings with lots
of random characters).  This makes it very hard to develop anything in
Script-Fu while looking up stuff in the PDB, because each change to the
script requires re-starting the GIMP.

Interestingly, this problem does not seem to occur with Tiny-Fu.  I can
refresh scripts as much as I want and the PDB browser is still working fine.

Steps to reproduce:
- start GIMP
- Xtns -> Script-Fu -> Refresh Scripts
- Xtns -> Procedure Browser
The plug-in crashes: glibc reports an invalid pointer passed to free().
Comment 1 Sven Neumann 2006-05-22 14:41:42 UTC
I can't reproduce the problem and valgrind doesn't seem to see any errors. Perhaps we need a more detailed description on how to reproduce this.
Comment 2 Raphaël Quinet 2006-05-23 19:54:33 UTC
OK, it looks like the problem occurs only after installing Tiny-Fu.  I try to
start from a clean $PREFIX and I did a "make clean && make && make install"
in gimp (CVS HEAD) and gimp-tiny-fu (CVS HEAD).

If I only have gimp installed in $PREFIX, everything seems to work fine, no
matter how often I refresh the scripts.

But after re-installing Tiny-Fu, I start seeing the crashes in the procedure
browser soon after refreshing Script-Fu.  It does not occur the first time I
run gimp, but it occurs afterwards.
Comment 3 Raphaël Quinet 2006-05-23 20:29:48 UTC
I attached to the procedure_browser plug-in using gdb (and GIMP_PLUGIN_DEBUG)
and I got the following stack trace:

Program received signal SIGABRT, Aborted.
0xb76c17c7 in raise () from /lib/tls/libc.so.6
(gdb) bt
  • #0 raise
    from /lib/tls/libc.so.6
  • #1 abort
    from /lib/tls/libc.so.6
  • #2 __fsetlocking
    from /lib/tls/libc.so.6
  • #3 malloc_usable_size
    from /lib/tls/libc.so.6
  • #4 free
    from /lib/tls/libc.so.6
  • #5 g_free
    from /usr/lib/libglib-2.0.so.0
  • #6 gimp_destroy_paramdefs
    at gimp.c line 1010
  • #7 browser_selection_changed
    at gimpprocbrowserdialog.c line 361
  • #8 g_cclosure_marshal_VOID__VOID
    from /usr/lib/libgobject-2.0.so.0
  • #9 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #10 g_signal_stop_emission
    from /usr/lib/libgobject-2.0.so.0
  • #11 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #12 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #13 _gtk_tree_selection_internal_select_node
    from /usr/lib/libgtk-x11-2.0.so.0
  • #14 gtk_tree_selection_select_path
    from /usr/lib/libgtk-x11-2.0.so.0
  • #15 gtk_tree_selection_select_iter
    from /usr/lib/libgtk-x11-2.0.so.0
  • #16 browser_search
    at gimpprocbrowserdialog.c line 509
  • #17 gimp_proc_browser_dialog_new
    at gimpprocbrowserdialog.c line 241
  • #18 run
    at procedure-browser.c line 125
  • #19 gimp_main
    at gimp.c line 1799
  • #20 main
    at procedure-browser.c line 72

Comment 4 Michael Natterer 2006-05-23 22:41:48 UTC
Fixed in CVS:

2006-05-24  Michael Natterer  <mitch@gimp.org>

	* app/pdb/gimppdb.c (gimp_pdb_real_register_procedure)
	(gimp_pdb_real_unregister_procedure): use g_hash_table_replace()
	instead of g_hash_table_insert() and make sure the used key is
	always the name of the first procedure in the list.
	Fixes bug #342578.
	
	(It's actually a miracle that only the PDB browser crashed, and
	not GIMP, since we were using pointers to g_free()'d memory as
	keys when different plug-ins registered procedures with the same
	name)
Comment 5 Sven Neumann 2006-05-24 07:03:59 UTC
Since 2.2 seems to have a very similar problem, perhaps it should be fixed there as well?
Comment 6 Michael Natterer 2006-05-24 08:02:51 UTC
2.2 unregisters the procedure by *name* and always removes the first element
of the list of procedures which have the same name, so e.g. script-fu
will happily remove a tiny-fu procedure, or vice versa, depending
on their file system order and depending on where you click refresh.

It's so broken, we should just ignore it.
Comment 7 Sven Neumann 2006-05-24 09:01:31 UTC
OK. If it can't easily be fixed, we should better not touch that code in the stable branch.
Comment 8 Raphaël Quinet 2006-05-24 10:55:00 UTC
Just in case anybody looks at this bug and does not understand what was
going on, here is a summary of the findings after the crazy debugging night
that I had with mitch:
- One of the Script-Fu scripts (web-browser.scm) is registering several
  procedures in the PDB without using the script-fu-* namespace.
- This script was translated to Tiny-Fu (web-browser.sct) but the procedure
  names were not changed since they did not contain script-fu-* (which
  would have been mapped to tiny-fu-*).  As a result, any user who had
  both Script-Fu and Tiny-Fu installed got some procedures registered twice.
  This is a minor thing that should not have caused any crash.
- Unfortunately, the code in app/pdb/gimppdb.c did not handle this case
  correctly.  As mitch mentioned in comment #4, some pointers used for keys
  in the hash table were freed but still used.  After refreshing the list
  of scripts for Script-Fu, the hash table was corrupted and some keys (the
  ones associated with the procedures registered twice) contained random
  garbage.
- The main process was apparently not affected much, but the procedure
  broswer plug-in crashed when it tried to use the invalid keys.  It may
  have been possible to crash the main application when trying to access
  the procedures registered by web-browser.scm, but I did not test that.