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 382565 - GtkTextView invisible text crash
GtkTextView invisible text crash
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
2.10.x
Other All
: Normal critical
: ---
Assigned To: gtk-bugs
gtk-bugs
: 363602 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-12-05 11:04 UTC by Kostya
Modified: 2007-02-20 09:02 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16



Description Kostya 2006-12-05 11:04:56 UTC
Steps to reproduce:
1.  make simple app :

#include <gtk/gtk.h>

int main(int argc,char *argv[])
{
GtkWidget *wnd;
GtkWidget *view;
GtkTextBuffer *buff;
GtkTextIter stiter;

gtk_init(&argc,&argv);

view = gtk_text_view_new ();

buff = gtk_text_view_get_buffer ( GTK_TEXT_VIEW ( view ) );

gtk_text_buffer_get_start_iter( buff, &stiter );

gtk_text_buffer_create_tag ( buff, "Embed", "invisible", TRUE, NULL );

gtk_text_buffer_insert ( buff, &stiter, "Normal text ", -1 );

gtk_text_buffer_insert_with_tags_by_name( buff, &stiter, ":)", 2, "Embed", NULL );

gtk_text_buffer_insert ( buff, &stiter, " Normal text", -1 );

wnd = gtk_window_new ( GTK_WINDOW_TOPLEVEL );

gtk_container_add ( GTK_CONTAINER (wnd), view);

gtk_widget_show_all( wnd );

gtk_main();

return 0;
}

2. compile it and run

3. go too next line by pressing return key at the end of line. Type some text and press return, than type some more text and press return.
For example :
Normal text Normal text[Enter]
aaaaaaaaaaaaaaaaaaaaaaa[Enter]
bbbbbbbbbbbbbbbbbbbbbbb[Enter]

4. Then press left arrow key to move to the begin of text
For example abov move from empty line to line with Normal text using left arrow

5. But app will crash when you move from first character of second line to last character of first line.



Stack trace:
Program output

(tst:11379): Gtk-WARNING **: gtktextbtree.c:3974: byte index off the end of the line

Gtk-ERROR **: Byte index 29 is off the end of the line
aborting...
Aborted



Other information:
This bug come only when you use invisible text in GtkTextView.
App was tested at gtk+ 2.8 and 2.10 .
Comment 1 Kjartan Maraas 2007-02-09 16:10:52 UTC
Could you paste a backtrace from gdb here please?
Comment 2 Kostya 2007-02-15 10:17:07 UTC


  • #0 __kernel_vsyscall
  • #1 raise
    from /lib/libc.so.6
  • #2 abort
    from /lib/libc.so.6
  • #3 g_logv
    from /opt/gnome/lib/libglib-2.0.so.0
  • #4 g_log
    from /opt/gnome/lib/libglib-2.0.so.0
  • #5 gtk_text_layout_draw
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #6 gtk_text_iter_set_visible_line_index
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #7 gtk_text_layout_get_iter_at_line
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #8 gtk_text_layout_move_iter_visually
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #9 gtk_text_view_new_with_buffer
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #10 gtk_marshal_BOOLEAN__VOID
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #11 g_value_set_static_boxed
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #12 g_closure_invoke
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #13 g_signal_connect_closure_by_id
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #14 g_signal_emitv
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #15 gtk_binding_set_new
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #16 gtk_binding_set_new
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #17 gtk_binding_set_new
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #18 gtk_bindings_activate_event
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #19 gtk_widget_freeze_child_notify
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #20 gtk_text_view_new_with_buffer
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #21 gtk_marshal_BOOLEAN__VOID
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #22 g_value_set_static_boxed
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #23 g_closure_invoke
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #24 g_signal_connect_closure_by_id
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #25 g_signal_emit_valist
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #26 g_signal_emit
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #27 gtk_widget_get_default_style
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #28 gtk_window_propagate_key_event
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #29 gtk_window_activate_key
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #30 gtk_marshal_BOOLEAN__VOID
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #31 g_value_set_static_boxed
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #32 g_closure_invoke
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #33 g_signal_connect_closure_by_id
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #34 g_signal_emit_valist
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #35 g_signal_emit
    from /opt/gnome/lib/libgobject-2.0.so.0
  • #36 gtk_widget_get_default_style
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #37 gtk_propagate_event
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #38 gtk_main_do_event
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #39 gdk_add_client_message_filter
    from /opt/gnome/lib/libgdk-x11-2.0.so.0
  • #40 g_main_context_dispatch
    from /opt/gnome/lib/libglib-2.0.so.0
  • #41 g_main_context_check
    from /opt/gnome/lib/libglib-2.0.so.0
  • #42 g_main_loop_run
    from /opt/gnome/lib/libglib-2.0.so.0
  • #43 gtk_main
    from /opt/gnome/lib/libgtk-x11-2.0.so.0
  • #44 main
    at test.c line 32

I'm used SUSE 10.1
Comment 3 Matthias Clasen 2007-02-18 15:18:30 UTC
Looks like gtk_text_layout_move_iter_visually is busted when moving between
paragraphs containing invisible text, since use byte counts without taking visibility into account.
Comment 4 Matthias Clasen 2007-02-18 16:53:23 UTC
2007-02-18  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtktextlayout.c (gtk_text_layout_move_iter_visually):
        Ignore invisible text when going to end of the previous line.
        (#382565)
Comment 5 Richard Hult 2007-02-20 09:02:15 UTC
*** Bug 363602 has been marked as a duplicate of this bug. ***