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 379112 - Crashes when copy-pasting text
Crashes when copy-pasting text
Status: RESOLVED FIXED
Product: gtranslator
Classification: Other
Component: general
1.1.x
Other Linux
: Normal major
: 2.0
Assigned To: Ross Golder
Ross Golder
: 344133 348687 350277 351081 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-11-25 12:55 UTC by Loïc Minier
Modified: 2006-11-28 00:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Nullify selection_buffer after g_free()ing it; probably fixes double free() (474 bytes, patch)
2006-11-25 12:56 UTC, Loïc Minier
none Details | Review
g_object_unref() selection_buffer instead of g_free()ing it (486 bytes, patch)
2006-11-27 14:38 UTC, Loïc Minier
none Details | Review

Description Loïc Minier 2006-11-25 12:55:25 UTC
Hi,

Martin Hawlisch reported in Debian bug http://bugs.debian.org/400048:
"""I'm using gtranslator to edit the german po file of GRAMPS.
Especially when doing copy and past in the translation field gtranslator crashes
very often.
It prints to the console:
*** glibc detected *** free(): invalid pointer: 0x089a3c28 ***
and then is hanging.
"""

He produced a valgrind log with a gtranslator rebuilt with debugging symbols and I wrote a patch which probably fixes the issue which I'm going to attach.

Bye,
Comment 1 Loïc Minier 2006-11-25 12:56:22 UTC
Created attachment 77123 [details] [review]
Nullify selection_buffer after g_free()ing it; probably fixes double free()
Comment 2 Ross Golder 2006-11-25 14:00:35 UTC
The patch doesn't appear to do anything useful. The selection_buffer is reset anyway on the next line.
Comment 3 Loïc Minier 2006-11-25 15:25:35 UTC
Oops.

Well, I tried breaking on the gtk_text_buffer_new(), noting down the allocated address, then breaking on free() and realloc() if the corresponding register is set to this address (I used $eax for free and $esi for realloc), but I only got a *single* hit on the free() breakpoint, after which I get the double free() warning from glibc.   :-(
Comment 4 Loïc Minier 2006-11-25 15:33:52 UTC
Running under G_SLICE=always-malloc doesn't crash, I suppose that means that some code is calling free() instead of g_free().
Comment 5 Loïc Minier 2006-11-25 15:49:30 UTC
I linked gtranslator with --as-needed and listed all directly linked libraries.  The following libs from this list are calling libc's free():
/lib/libpopt.so.0
/usr/lib/libgnomevfs-2.so.0
/usr/lib/libxml2.so.2
/usr/lib/libgtk-x11-2.0.so.0
/usr/lib/libgdk-x11-2.0.so.0
/usr/lib/libglib-2.0.so.0

Glib is obviously normal.  libpopt and libxml2 aren't using glib.

Could it be a Gtk or Gnome-VFS bug?
Comment 6 Loïc Minier 2006-11-27 14:38:14 UTC
Created attachment 77213 [details] [review]
g_object_unref() selection_buffer instead of g_free()ing it
Comment 7 Loïc Minier 2006-11-27 14:39:13 UTC
(Dafydd Harries explained the issue to me, so he's the one to credit for the patch.)
Comment 8 Dafydd Harries 2006-11-27 14:39:46 UTC
This is not a double free; it's simply that the text buffer is a GObject and should be memory-managed with g_object_unref() instead of free(). The crash doesn't happen with G_SLICE=always-malloc because this means that the GtkTextBuffer object is then allocated using malloc() instead of from a slice, which means free() can be called on it without causing a crash.
Comment 9 Ross Golder 2006-11-27 23:17:47 UTC
Fixed in CVS. Will roll a 1.1.7 release shortly containing this patch. Thanks, guys.
Comment 10 Ross Golder 2006-11-28 00:32:42 UTC
*** Bug 348687 has been marked as a duplicate of this bug. ***
Comment 11 Ross Golder 2006-11-28 00:32:56 UTC
*** Bug 139738 has been marked as a duplicate of this bug. ***
Comment 12 Ross Golder 2006-11-28 00:34:52 UTC
*** Bug 344133 has been marked as a duplicate of this bug. ***
Comment 13 Ross Golder 2006-11-28 00:35:38 UTC
*** Bug 350277 has been marked as a duplicate of this bug. ***
Comment 14 Ross Golder 2006-11-28 00:38:32 UTC
*** Bug 351081 has been marked as a duplicate of this bug. ***