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 735337 - Crash in inspector, in the CSS editor
Crash in inspector, in the CSS editor
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Debugging
3.13.x
Other Linux
: Normal critical
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-08-24 19:25 UTC by Sébastien Wilmet
Modified: 2014-08-25 12:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
inspector: fix a crash in the CSS editor (3.22 KB, patch)
2014-08-24 19:28 UTC, Sébastien Wilmet
committed Details | Review

Description Sébastien Wilmet 2014-08-24 19:25:56 UTC
When using the inspector, I got a crash:
> Gtk-ERROR **: Byte index 2 is off the end of the line

See the attached patch to fix the problem.

It happens with the following steps:

Write custom CSS like:

.left {
 background-color: white;
}

Try to comment the background-color: write /* just before the 'b'.

In the following backtrace, show_parsing_error() is called (frame 7) and calls gtk_text_buffer_get_iter_at_line_index() with an invalid byte index (line 9 is the last line, which contains only the character '}', but byte_index is 2).


  • #0 _g_log_abort
    at gmessages.c line 315
  • #1 g_logv
    at gmessages.c line 1041
  • #2 g_log
    at gmessages.c line 1079
  • #3 iter_set_from_byte_offset
    at gtktextiter.c line 121
  • #4 iter_init_from_byte_offset
    at gtktextiter.c line 285
  • #5 _gtk_text_btree_get_iter_at_line_byte
    at gtktextiter.c line 5592
  • #6 gtk_text_buffer_get_iter_at_line_index
    at gtktextbuffer.c line 2907
  • #7 show_parsing_error
    at css-editor.c line 276
  • #8 _gtk_marshal_VOID__BOXED_BOXED
    at gtkmarshalers.c line 2984
  • #9 g_closure_invoke
    at gclosure.c line 768
  • #10 signal_emit_unlocked_R
    at gsignal.c line 3553
  • #11 g_signal_emit_valist
    at gsignal.c line 3309
  • #12 g_signal_emit
    at gsignal.c line 3365
  • #13 gtk_css_provider_emit_error
    at gtkcssprovider.c line 1469
  • #14 gtk_css_scanner_parser_error
    at gtkcssprovider.c line 1480
  • #15 _gtk_css_parser_take_error
    at gtkcssparser.c line 175
  • #16 _gtk_css_parser_error
    at gtkcssparser.c line 195
  • #17 gtk_css_parser_skip_comment
    at gtkcssparser.c line 267
  • #18 _gtk_css_parser_skip_whitespace
    at gtkcssparser.c line 288
  • #19 _gtk_css_parser_try
    at gtkcssparser.c line 307
  • #20 parse_ruleset
    at gtkcssprovider.c line 2553
  • #21 parse_statement
    at gtkcssprovider.c line 2595
  • #22 parse_stylesheet
    at gtkcssprovider.c line 2611
  • #23 gtk_css_provider_load_internal
    at gtkcssprovider.c line 2727
  • #24 gtk_css_provider_load_from_data
    at gtkcssprovider.c line 2794
  • #25 update_style
    at css-editor.c line 234
  • #26 update_timeout
    at css-editor.c line 247
  • #27 g_timeout_dispatch
    at gmain.c line 4473
  • #28 g_main_dispatch
    at gmain.c line 3064
  • #29 g_main_context_dispatch
    at gmain.c line 3663
  • #30 g_main_context_iterate
    at gmain.c line 3734
  • #31 g_main_context_iteration
    at gmain.c line 3795
  • #32 g_application_run
    at gapplication.c line 2219
  • #33 __libc_csu_init
  • #34 ??
  • #35 ??
  • #36 main
    at main.c line 1024

Comment 1 Sébastien Wilmet 2014-08-24 19:28:53 UTC
Created attachment 284356 [details] [review]
inspector: fix a crash in the CSS editor

gtk_css_section_get_end_position() can return a position one byte beyond
the end of the last line.

gtk_text_buffer_get_iter_at_line_index() accepts only valid
line_number/byte_index pairs. Another solution is to make the
GtkTextBuffer function less strict, by returning a boolean if the exact
position was found.

The CSS parser should also be fixed to always return valid positions.
But it's better to have a safety net in the CSS editor, just in case (a
warning could be print).
Comment 2 Sébastien Wilmet 2014-08-24 21:26:54 UTC
See bug #735341 to fix the problem in GtkTextBuffer.
Comment 3 Matthias Clasen 2014-08-25 12:11:18 UTC
Review of attachment 284356 [details] [review]:

I guess that is an ok short-term fix, until we have safer text iter apis