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 742015 - Code snippets plugin crashes gedit when autocompleting html's "doctype" snippet
Code snippets plugin crashes gedit when autocompleting html's "doctype" snippet
Status: RESOLVED FIXED
Product: gedit-plugins
Classification: Other
Component: General
3.14.x
Other Linux
: Normal critical
: ---
Assigned To: Gedit maintainers
Gedit maintainers
Depends on:
Blocks:
 
 
Reported: 2014-12-27 02:27 UTC by Jean-François Fortin Tam
Modified: 2019-03-23 20:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix AttributeError (924 bytes, patch)
2015-01-02 08:41 UTC, Sagar Gangurde
needs-work Details | Review

Description Jean-François Fortin Tam 2014-12-27 02:27:40 UTC
$ touch foo.html
$ gedit foo.html

Type "doctype", press the Tab key... and you get:


(gedit:2328): Gtk-CRITICAL **: gtk_text_view_get_iter_location: assertion 'gtk_text_iter_get_buffer (iter) == get_buffer (text_view)' failed

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6cfd760 in _gtk_text_btree_get_chars_changed_stamp () from /lib64/libgtk-3.so.0
(gdb) bt full
  • #0 _gtk_text_btree_get_chars_changed_stamp
  • #1 gtk_text_iter_make_surreal
  • #2 gtk_text_iter_get_buffer
  • #3 gtk_text_view_get_iter_location
  • #4 move_to_iter
  • #5 gtk_source_completion_info_move_to_iter
  • #6 update_window_position
  • #7 g_closure_invoke
  • #8 signal_emit_unlocked_R
  • #9 g_signal_emit_valist
  • #10 g_signal_emit
  • #11 gtk_widget_size_allocate_with_baseline
  • #12 gtk_window_show
  • #13 g_closure_invoke
  • #14 signal_emit_unlocked_R
  • #15 g_signal_emit_valist
  • #16 g_signal_emit
  • #17 gtk_widget_show
  • #18 gtk_source_completion_show_default
  • #19 _g_closure_invoke_va
  • #20 g_signal_emit_valist
  • #21 g_signal_emit
  • #22 ffi_call_unix64
  • #23 ffi_call
  • #24 pygi_invoke_c_callable
  • #25 pygi_function_cache_invoke
  • #26 _callable_info_call
  • #27 PyObject_Call
  • #28 PyEval_EvalFrameEx
  • #29 PyEval_EvalCodeEx
  • #30 function_call
  • #31 PyObject_Call
  • #32 PyEval_CallObjectWithKeywords
  • #33 _pygi_closure_handle
  • #34 ffi_closure_unix64_inner
  • #35 ffi_closure_unix64
  • #36 update_completion
  • #37 gtk_source_completion_show
  • #38 ffi_call_unix64
  • #39 ffi_call
  • #40 pygi_invoke_c_callable
  • #41 pygi_function_cache_invoke
  • #42 _callable_info_call
  • #43 PyObject_Call
  • #44 PyEval_EvalFrameEx
  • #45 PyEval_EvalFrameEx
  • #46 PyEval_EvalFrameEx
  • #47 PyEval_EvalCodeEx
  • #48 function_call
  • #49 PyObject_Call
  • #50 method_call
  • #51 PyObject_Call
  • #52 PyEval_CallObjectWithKeywords
  • #53 pygi_signal_closure_marshal
  • #54 g_closure_invoke
  • #55 signal_emit_unlocked_R
  • #56 g_signal_emit_valist
  • #57 g_signal_emit
  • #58 gtk_widget_event_internal
  • #59 gtk_window_propagate_key_event
  • #60 gedit_window_key_press_event
  • #61 _gtk_marshal_BOOLEAN__BOXEDv
  • #62 _g_closure_invoke_va
  • #63 g_signal_emit_valist
  • #64 g_signal_emit
  • #65 gtk_widget_event_internal
  • #66 propagate_event
  • #67 gtk_main_do_event
  • #68 gdk_event_source_dispatch
  • #69 g_main_context_dispatch
  • #70 g_main_context_iterate.isra
  • #71 g_main_context_iteration
  • #72 g_application_run
  • #73 main

Comment 1 Sébastien Wilmet 2014-12-28 20:03:43 UTC
Thanks for the bug report and the backtrace.

When trying to reproduce the bug, I got this instead:

Traceback (most recent call last):
  • File "/opt/gnome/lib/gedit/plugins/snippets/completion.py", line 117 in do_populate
    proposals = self.get_proposals(self.get_word(context))
  • File "/opt/gnome/lib/gedit/plugins/snippets/completion.py", line 79 in get_word
    if it.starts_word() or it.starts_line() or not it.ends_word():
AttributeError: 'tuple' object has no attribute 'starts_word'


I'll try to fix this soon.
Comment 2 Sagar Gangurde 2015-01-02 08:41:28 UTC
Created attachment 293592 [details] [review]
Fix AttributeError
Comment 3 Sébastien Wilmet 2015-01-02 10:10:21 UTC
Review of attachment 293592 [details] [review]:

I don't know the syntax in Python, but you should get the boolean return value too.
Comment 4 Sébastien Wilmet 2015-01-03 16:48:12 UTC
The bug seems to be 100% reproducible with gedit/gtksourceview 3.14. It's maybe already fixed in 3.15, but the snippets plugin needs to be updated first.

Here is a more detailed backtrace (with 3.14) with a breakpoint at the critical message:

(gedit:14758): Gtk-CRITICAL **: gtk_text_view_get_iter_location: assertion 'gtk_text_iter_get_buffer (iter) == get_buffer (text_view)' failed

(gdb) bt
  • #0 g_logv
    at gmessages.c line 1046
  • #1 g_log
    at gmessages.c line 1079
  • #2 g_return_if_fail_warning
    at gmessages.c line 1088
  • #3 gtk_text_view_get_iter_location
    at gtktextview.c line 1960
  • #4 move_to_iter
    at gtksourcecompletioninfo.c line 374
  • #5 move_to_iter
    at gtksourcecompletioninfo.c line 478
  • #6 gtk_source_completion_info_move_to_iter
    at gtksourcecompletioninfo.c line 571
  • #7 update_window_position
    at gtksourcecompletion.c line 494
  • #8 _g_closure_invoke_va
    at gclosure.c line 831
  • #9 g_signal_emit_valist
    at gsignal.c line 3218
  • #10 g_signal_emit
    at gsignal.c line 3365
  • #11 _gtk_tree_selection_internal_select_node
    at gtktreeselection.c line 1594
  • #12 gtk_tree_selection_select_path
    at gtktreeselection.c line 897
  • #13 gtk_tree_selection_select_iter
    at gtktreeselection.c line 975
  • #14 check_first_selected
    at gtksourcecompletion.c line 305
  • #15 _gtk_source_completion_add_proposals
    at gtksourcecompletion.c line 1576
  • #16 _gtk_source_completion_add_proposals
    at gtksourcecompletion.c line 2620
  • #17 ffi_call_unix64
    at ../src/x86/unix64.S line 76
  • #18 ffi_call
    at ../src/x86/ffi64.c line 525
  • #19 pygi_invoke_c_callable
  • #20 pygi_function_cache_invoke
  • #21 _callable_info_call
  • #22 PyObject_Call
  • #23 PyEval_EvalFrameEx
  • #24 PyEval_EvalCodeEx
  • #25 function_call
  • #26 PyObject_Call
  • #27 PyEval_CallObjectWithKeywords
  • #28 _pygi_closure_handle
  • #29 ffi_closure_unix64_inner
    at ../src/x86/ffi64.c line 670
  • #30 ffi_closure_unix64
    at ../src/x86/unix64.S line 229
  • #31 update_completion
    at gtksourcecompletion.c line 1380
  • #32 gtk_source_completion_show
    at gtksourcecompletion.c line 2687
  • #33 ffi_call_unix64
    at ../src/x86/unix64.S line 76
  • #34 ffi_call
    at ../src/x86/ffi64.c line 525
  • #35 pygi_invoke_c_callable
  • #36 pygi_function_cache_invoke
  • #37 _callable_info_call
  • #38 PyObject_Call
  • #39 PyEval_EvalFrameEx
  • #40 PyEval_EvalFrameEx
  • #41 PyEval_EvalFrameEx
  • #42 PyEval_EvalCodeEx
  • #43 function_call
  • #44 PyObject_Call
  • #45 method_call
  • #46 PyObject_Call
  • #47 PyEval_CallObjectWithKeywords
  • #48 pygi_signal_closure_marshal
  • #52 <emit signal ??? on instance 0x10fa460 [GeditView]>
    at gsignal.c line 3365
  • #53 gtk_widget_event_internal
    at gtkwidget.c line 7773
  • #54 gtk_window_propagate_key_event
    at gtkwindow.c line 7613
  • #55 gedit_window_key_press_event
    at gedit/gedit-window.c line 352
  • #56 _gtk_marshal_BOOLEAN__BOXEDv
    at gtkmarshalers.c line 130
  • #57 _g_closure_invoke_va
    at gclosure.c line 831
  • #58 g_signal_emit_valist
    at gsignal.c line 3218
  • #59 g_signal_emit
    at gsignal.c line 3365
  • #60 gtk_widget_event_internal
    at gtkwidget.c line 7773
  • #61 propagate_event
    at gtkmain.c line 2507
  • #62 gtk_main_do_event
    at gtkmain.c line 1748
  • #63 gdk_event_source_dispatch
    at gdkeventsource.c line 364
  • #64 g_main_context_dispatch
    at gmain.c line 3111
  • #65 g_main_context_dispatch
    at gmain.c line 3710
  • #66 g_main_context_iterate
    at gmain.c line 3781
  • #67 g_main_context_iteration
    at gmain.c line 3842
  • #68 g_application_run
    at gapplication.c line 2282
  • #69 main
    at gedit/gedit.c line 135

Comment 5 Sébastien Wilmet 2015-01-03 21:28:51 UTC
The snippets plugin is adapted:
https://git.gnome.org/browse/gedit/commit/?id=5540838a7dff1d025b995c251f51c1c29ce0c0ce

But it isn't completely fixed.
Comment 6 Sébastien Wilmet 2015-01-04 12:23:15 UTC
With these two branches:
https://git.gnome.org/browse/gedit/log/?h=wip/snippets-debug-messages
https://git.gnome.org/browse/gtksourceview/log/?h=wip/completion-debug-messages

(on git master, not 3.14)

Here is the output:

do_get_start_iter()
assign iter
iter offset in snippets: 0

(gedit:13348): Gtk-WARNING **: Invalid text buffer iterator: either the iterator is uninitialized, or the characters/pixbufs/widgets in the buffer have been modified since the iterator was created.
You must use marks, character numbers, or line numbers to preserve a position across buffer modifications.
You can apply tags and insert marks without invalidating your iterators,
but any mutation that affects 'indexable' buffer contents (contents that can be referred to by character offset)
will invalidate all outstanding iterators

-----

So iter.get_offset() works fine in the snippets plugin (in Python), but calling the same function in gtksourcecompletion (with the same iter) gives the warning message.

So I suspect a bug in pygobject or a missing introspection annotation (but where?).
Comment 7 Sébastien Wilmet 2015-01-04 15:03:03 UTC
Fixed, it was an annotation issue:
https://git.gnome.org/browse/gtksourceview/commit/?id=c6992936323b2f57637ecd18898de84bce164e56
https://git.gnome.org/browse/gedit/commit/?id=d48cd10bf0bb99ead7b1af1ead52f1e554ad239d

The commits are backported to the gnome-3-14 branches.

Thanks for the bug report!