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 65731 - GtkTextView with custom GtkTextBuffer dies after hitting 'Del' or 'BS'.
GtkTextView with custom GtkTextBuffer dies after hitting 'Del' or 'BS'.
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
1.3.x
Other All
: Normal critical
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2001-11-29 14:29 UTC by Vitaly Tishkov
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Vitaly Tishkov 2001-11-29 14:29:08 UTC
Test case:

#include <gtk/gtk.h>

int
main (int argc, char** argv)
{
    GtkWidget *view;
    GtkWidget *window;
    GtkTextBuffer* buffer;

    gtk_init (&argc, &argv);

    view = gtk_text_view_new ();
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);


/*      buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); */
/*      gtk_text_buffer_set_text (buffer, "0123456789\0", -1); */

    buffer = gtk_text_buffer_new (NULL);
    gtk_text_buffer_set_text (buffer, "0123456789\0", -1);
    gtk_text_view_set_buffer (GTK_TEXT_VIEW(view), buffer);

    gtk_container_add (GTK_CONTAINER (window), view);
    gtk_widget_show_all (window);

    gtk_main();
}


How to reproduce.
1. Compile and run the program.
2. Set the corsor to any position except start and end positions.
3. Press 'Delete' or 'Backspace' button.

The program dies producing this output:
1 lines in tree 0x8064190
   0| line: 0x8063f58 parent: 0x8063f30 next: 0x8063f70
     segment: 0x806d6a8 type: mark bytes: 0 chars: 0
       left mark `(null)' visible: 0 not_deleteable: 0
     segment: 0x806d650 type: mark bytes: 0 chars: 0
       right mark `gtk_drag_target' visible: 0 not_deleteable: 0
     segment: 0x8133fd8 type: character bytes: 7 chars: 7
       `0123456'
     segment: 0x8133990 type: mark bytes: 0 chars: 0
       left mark `(null)' visible: 0 not_deleteable: 0
     segment: 0x81339b8 type: character bytes: 1 chars: 1
       `7'
     segment: 0x81339d0 type: mark bytes: 0 chars: 0
       right mark `(null)' visible: 0 not_deleteable: 0
     segment: 0x8064288 type: mark bytes: 0 chars: 0
       right mark `insert' visible: 1 not_deleteable: 1
     segment: 0x80642f0 type: mark bytes: 0 chars: 0
       right mark `selection_bound' visible: 0 not_deleteable: 1
     segment: 0x806d630 type: character bytes: 3 chars: 3
       `89
'
   1| line: 0x8063f70 parent: 0x8063f30 next: (nil)
     segment: 0x8063fa0 type: character bytes: 1 chars: 1
       `
'
=================== Tag information
  (no tags in the tree)
=================== Tree nodes
node 0x8063f30 level 0 children 2 lines 2 chars 12
  line 0x8063f58 chars 11 bytes 11
   left mark `(null)' visible: 0
   right mark `gtk_drag_target' visible: 0
   chars `0123456'...
   left mark `(null)' visible: 0
   chars `7'...
   right mark `(null)' visible: 0
   right mark `insert' visible: 1
   right mark `selection_bound' visible: 0
   chars `89\'...
  line 0x8063f70 chars 1 bytes 1
   chars `\'...

test (pid:26538): Gtk-ERROR **: file gtktextiter.c: line 2021
(_gtk_text_iter_forward_indexable_segment): assertion failed:
(gtk_text_iter_is_end (iter))
aborting...
Trace/breakpoint trap


Important! If you uncomment the commented strings in the program source
code and comment the next three strings (i.e. change the buffer
initialization) the bug in not reproducible.


The bug looks very similar to #64883 but probably is not its duplicate.
Comment 1 Havoc Pennington 2001-11-29 20:09:46 UTC
Was a bug in _gtk_text_iter_forward_indexable_segment() that depended
on the exact segment structure of the btree; setting text on the
buffer while it was in the view resulted in slightly different marks
and thus different segments than setting text before placing the
buffer in the view.

2001-11-29  Havoc Pennington  <hp@redhat.com>

	* gtk/gtktextiter.c (_gtk_text_iter_forward_indexable_segment):
	assertion here that we were at the end iterator was not correct;
	change code to move us to the end iterator. bug #65731