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 672789 - gtk_builder_add_objects_from_file() crashes on GtkUIManager markup
gtk_builder_add_objects_from_file() crashes on GtkUIManager markup
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkBuilder
3.3.x
Other All
: Normal critical
: ---
Assigned To: GtkBuilder maintainers
GtkBuilder maintainers
Depends on:
Blocks:
 
 
Reported: 2012-03-25 10:01 UTC by Philip Withnall
Modified: 2012-04-20 05:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Minimal test case (C code) (476 bytes, text/plain)
2012-03-31 02:10 UTC, Philip Withnall
  Details
Minimal test case (UI file) (949 bytes, text/plain)
2012-03-31 02:10 UTC, Philip Withnall
  Details
Fix a cornercase of menu parsing (1.20 KB, patch)
2012-04-20 05:51 UTC, Matthias Clasen
committed Details | Review

Description Philip Withnall 2012-03-25 10:01:52 UTC
If I have a GtkBuilder file with (for example) two objects: my_random_object and my_ui_manager (with an embedded <menubar>, just like in Example 81 from http://developer.gnome.org/gtk3/unstable/GtkUIManager.html), calling gtk_builder_add_objects_from_file(builder, "my.ui", { "my_random_object", NULL) will crash with the following backtrace.

Adding "my_ui_manager" to the list of objects IDs passed to gtk_builder_add_objects_from_file() works normally and doesn't crash.

It appears that if "my_ui_manager" isn't in the list of objects, its <ui> and <menu> elements are parsed using the wrong parser, causing the crash.

Backtrace:

**
GLib:ERROR:gmarkup.c:2079:g_markup_parse_context_pop: assertion failed: (context->awaiting_pop)

Program received signal SIGABRT, Aborted.
0x000000350a036285 in raise () from /lib64/libc.so.6
(gdb) bt full
  • #0 raise
    from /lib64/libc.so.6
  • #1 abort
    from /lib64/libc.so.6
  • #2 g_assertion_message
  • #3 g_assertion_message_expr
    at gtestutils.c line 1872
  • #4 g_markup_parse_context_pop
    at gmarkup.c line 2079
  • #5 _gtk_builder_menu_end
    at gtkbuilder-menus.c line 386
  • #6 end_element
    at gtkbuilderparser.c line 968
  • #7 g_markup_parse_context_parse
    at gmarkup.c line 1559
  • #8 _gtk_builder_parser_parse_buffer
    at gtkbuilderparser.c line 1175
  • #9 gtk_builder_add_objects_from_file
    at gtkbuilder.c line 966
  • #10 almanah_search_dialog_new
    at search-dialog.c line 90
  • #11 mw_search_activate_cb
    at main-window.c line 963
  • #12 g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 85
  • #13 g_closure_invoke
    at gclosure.c line 777
  • #14 signal_emit_unlocked_R
    at gsignal.c line 3547
  • #15 g_signal_emit_valist
    at gsignal.c line 3296
  • #16 g_signal_emit
    at gsignal.c line 3352
  • #17 _gtk_action_emit_activate
    at gtkaction.c line 800
  • #18 gtk_action_activate
    at gtkaction.c line 830
  • #19 gtk_real_menu_item_activate
    at gtkmenuitem.c line 1760
  • #20 g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 85
  • #21 g_type_class_meta_marshal
    at gclosure.c line 970
  • #22 g_closure_invoke
    at gclosure.c line 777
  • #23 signal_emit_unlocked_R
    at gsignal.c line 3477
  • #24 g_signal_emit_valist
    at gsignal.c line 3296
  • #25 g_signal_emit
    at gsignal.c line 3352
  • #26 gtk_widget_activate
    at gtkwidget.c line 6411
  • #27 gtk_menu_shell_activate_item
    at gtkmenushell.c line 1429
  • #28 gtk_menu_shell_button_release
    at gtkmenushell.c line 830
  • #29 gtk_menu_button_release
    at gtkmenu.c line 3427
  • #30 _gtk_marshal_BOOLEAN__BOXEDv
    at gtkmarshalers.c line 130
  • #31 g_type_class_meta_marshalv
    at gclosure.c line 997
  • #32 _g_closure_invoke_va
    at gclosure.c line 840
  • #33 g_signal_emit_valist
    at gsignal.c line 3207
  • #34 g_signal_emit
    at gsignal.c line 3352
  • #35 gtk_widget_event_internal
    at gtkwidget.c line 6380
  • #36 gtk_widget_event
    at gtkwidget.c line 6037
  • #37 propagate_event_up
    at gtkmain.c line 2390
  • #38 propagate_event
    at gtkmain.c line 2490
  • #39 gtk_propagate_event
    at gtkmain.c line 2525
  • #40 gtk_main_do_event
    at gtkmain.c line 1713
  • #41 _gdk_event_emit
    at gdkevents.c line 69
  • #42 gdk_event_source_dispatch
    at gdkeventsource.c line 358
  • #43 g_main_dispatch
    at gmain.c line 2515
  • #44 g_main_context_dispatch
    at gmain.c line 3052
  • #45 g_main_context_iterate
    at gmain.c line 3123
  • #46 g_main_context_iteration
    at gmain.c line 3184
  • #47 g_application_run
    at gapplication.c line 1496
  • #48 main
    at main.c line 38

Comment 1 Matthias Clasen 2012-03-31 00:52:25 UTC
Can you attach an example that causes this problem for you ?
My attempt at creating a builder file according to your description didn't give me any crashes...
Comment 2 Philip Withnall 2012-03-31 02:10:34 UTC
Created attachment 211010 [details]
Minimal test case (C code)

Here we go. UI file coming in a second. Stick these in the same directory, compile using the command at the top of the C file.

 - Running without removing line 11 of the C file is fine.
 - Removing line 11 of the C file causes the crash.

I can reproduce this consistently with GTK+ (master, d7cf9d7b84d3e9188baf6637809b4bb61a48453c).
Comment 3 Philip Withnall 2012-03-31 02:10:57 UTC
Created attachment 211011 [details]
Minimal test case (UI file)
Comment 4 Matthias Clasen 2012-04-20 05:51:38 UTC
The following fix has been pushed:
aa3d30e Fix a cornercase of menu parsing
Comment 5 Matthias Clasen 2012-04-20 05:51:45 UTC
Created attachment 212402 [details] [review]
Fix a cornercase of menu parsing

When a uimanager in a gtkbuilder file contains a menu,
the builder parser was getting confused.