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 334399 - assertion crash in gtk_source_view_init()
assertion crash in gtk_source_view_init()
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
unspecified
Other All
: Normal blocker
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2006-03-13 09:13 UTC by Mitch
Modified: 2011-02-04 16:10 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16


Attachments
Does this patch fix the problem? (3.88 KB, patch)
2006-03-21 13:09 UTC, Michael Natterer
committed Details | Review

Description Mitch 2006-03-13 09:13:18 UTC
Steps to reproduce:
1. Compile glib with --disable-debug
2. Build gtksourceview 1.6.0 
3. Build gedit


Stack trace:
laptop ~% gdb gedit
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) r
Starting program: /usr/bin/gedit
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 30786)]

GtkSourceView-CRITICAL **: gtk_source_view_init: assertion `tl != NULL' failed
aborting...

Program received signal SIGABRT, Aborted.

Thread 16384 (LWP 30786)

  • #0 kill
    from /lib/libc.so.6
  • #1 pthread_kill
    from /lib/libpthread.so.0
  • #2 raise
    from /lib/libpthread.so.0
  • #3 raise
    from /lib/libc.so.6
  • #4 abort
    from /lib/libc.so.6
  • #5 g_logv
    from /usr/lib/libglib-2.0.so.0
  • #6 g_log
    from /usr/lib/libglib-2.0.so.0
  • #7 g_return_if_fail_warning
    from /usr/lib/libglib-2.0.so.0
  • #8 gtk_source_view_init
    at gtksourceview.c line 573
  • #9 g_type_create_instance
    from /usr/lib/libgobject-2.0.so.0
  • #10 g_object_constructor
    from /usr/lib/libgobject-2.0.so.0
  • #11 g_object_newv
    from /usr/lib/libgobject-2.0.so.0
  • #12 g_object_new_valist
    from /usr/lib/libgobject-2.0.so.0
  • #13 g_object_new
    from /usr/lib/libgobject-2.0.so.0
  • #14 gedit_view_new
  • #15 gedit_tab_get_state
  • #16 g_type_create_instance
    from /usr/lib/libgobject-2.0.so.0
  • #17 g_object_constructor
    from /usr/lib/libgobject-2.0.so.0
  • #18 g_object_newv
    from /usr/lib/libgobject-2.0.so.0
  • #19 g_object_new_valist
    from /usr/lib/libgobject-2.0.so.0
  • #20 g_object_new
    from /usr/lib/libgobject-2.0.so.0
  • #21 _gedit_tab_new
  • #22 gedit_window_create_tab
  • #23 main


Other information:
Comment 1 Mitch 2006-03-13 09:27:28 UTC
Note in the function gtk_source_view_init() the line

        g_return_if_fail (tl != NULL);

just calls g_return_if_fail_warning(), which calls g_log() which calls g_logv() whose default action is to call abort() ! So this the staement above is not having the intended effect i guess... 
Comment 2 Paolo Borelli 2006-03-15 17:38:43 UTC
well, an assertion it's an assertion: it's meant to be a sanity check that should never fails.

What we need to figure out is *why* tl is NULL.

Are you using gtk+ HEAD from cvs (2.9)?
Comment 3 Paolo Borelli 2006-03-15 19:47:19 UTC
Ok, looks like the breakage is due to the addition of rich text d'n'd to gtk:


<pbor> mitch: can your rtf dnd work have affected gtk_drag_dest_get_target_list (GTK_WIDGET (view)) ?
<pbor> (in the sense that it returns a null target list)
<mitch> pbor: definitely
<mitch> a NULL list?
<pbor> it broke gtksourceview :(
<mitch> it should definitely not do that, but get the target list from the buffer
<pbor> mitch: http://bugzilla.gnome.org/show_bug.cgi?id=334399
<pbor> mitch: behdad sees that too with gtk HEAD
<mclasen> pbor: whats the point of that return_if_fail ?!
<pbor> (ironic that the bug reporter is called mitch despite not being you :)
<pbor> mclasen: well, it's asserting that the target list is not null (I know using g_return_if_fail for that is not a good idea... not my code)
<mclasen> but...why ?
<pbor> mclasen: iirc gtksourceview adds support for dropping colors
* pbor looks at the code
<mclasen> yes, but why is it important that there are other targets supported by the text view before that ?
<mclasen> oh, now I see. You need t1 to be non-NULL to add to it...
<mclasen> well, if its null, you could just create a list yourself
<pbor> yeah
<mitch> hm that will fail badly
<mclasen> but it _is_ suspicious that it is null in the first place
<pbor> exactly
<mitch> since as soon as you set the buffer, the view uses the buffer's target list
<mitch> argh
<mitch> gah that's evil
<mclasen> mitch: clashes between toolkit-provided and app-provided targets are a recurring theme these days
<mclasen> cf notebook...
<mitch> that means richtext dnd breaks all users of GtkTextView which add their own drop targets
<mclasen> mitch: you probably need to be careful to preserve preexisting targets, or something
<mitch> mclasen: what about the "info" values in the list?
<mclasen> you mean if they clash ?
<mitch> yep
<mclasen> bad luck
<mitch> as in the standard enum { 0, 1, 2, ... } :(
<mitch> they will almost always clash
<mclasen> honestly, no idea
<mclasen> maybe reserve negative numbers for toolkit use...
<mitch> they are uint :/
<mitch> wait, are they?...
<mitch> they are
<mclasen> well, start counting down from MAXUINT then...
<mitch> yea
<mitch> in gtktextbuffer.h :(
<mclasen> right
<mitch> i will get something not entirely ugly hacked next week, after lgm
Comment 4 Paolo Borelli 2006-03-16 13:22:57 UTC
moving to gtk+
Comment 5 Michael Natterer 2006-03-21 13:09:32 UTC
Created attachment 61685 [details] [review]
Does this patch fix the problem?

Attached patch makes sure that the text view always has its
own target list. The text buffer's list is only used as source
to copy targets into the view's list.
Comment 6 Mitch 2006-03-21 15:32:51 UTC
Well it seems some change in recent CVS of gtk+ make gedit no longer crash even *without* your patch Michael. I now only get the CRITICAL warning, but no subsequent crash.

Comment 7 Paolo Borelli 2006-03-21 15:35:34 UTC
that was because gnome 2.14 was released: during developement versions (2.13) warnings intentionally cause assertions so that they do not go unnoticed.
Comment 8 Mitch 2006-03-21 15:38:37 UTC
So shall i still apply patch and report ?
Comment 9 Paolo Borelli 2006-03-21 15:42:14 UTC
yes, that would be great
Comment 10 Mitch 2006-03-21 15:51:51 UTC
Ok, so i've recompiled gtk+ with the patch above and there is no more warning and no more crash. It looks fine to me, but i'm sure needs a few more days testing..
Comment 11 Behdad Esfahbod 2006-03-21 16:22:55 UTC
Confirmed that the patch fixes it here.
Comment 12 Michael Natterer 2006-03-21 21:31:48 UTC
Does "fixes it" mean it doesn't warn/crash any more, or it
doesn't warn/crash *and* the additional drop tragets work?
Comment 13 Paolo Borelli 2006-03-21 21:38:25 UTC
In other words (since the feature is pretty obscure) Mitch, Behdad can you to do the following:
 - open the Edit->Preferences dialog and go to the Fonts&Colors tab
 - enable custom colors
 - press one of the colors buttons
 - From the Color chooser dialog drag the from the rectangle below the color below the wheel and drop it on the textview

It should insert #RRGGBB
Comment 14 Behdad Esfahbod 2006-03-21 21:50:16 UTC
Yes, DnDing the color works, and no warning.
Comment 15 Michael Natterer 2006-03-22 10:40:36 UTC
Thanks. Comitted the patch as-is:

2006-03-22  Michael Natterer  <mitch@imendio.com>

	* gtk/gtktextbuffer.h (enum GtkTextBufferTargetInfo): count down
	from G_MAXUINT to avoid clashes with application-added DND
	targets.

	* gtk/gtktextview.c (gtk_text_view_init): set an empty
	GtkTargetList on the drag_dest so it is not NULL when a derived
	class' init() function is called.

	(gtk_text_view_target_list_notify): copy the text buffer's paste
	targets into the view's destinstion target list (preserving
	application-added DND targets), instead of replacing the view's
	target list. Fixes bug #334399.