GNOME Bugzilla – Bug 672789
gtk_builder_add_objects_from_file() crashes on GtkUIManager markup
Last modified: 2012-04-20 05:51:45 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
+ Trace 229948
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...
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).
Created attachment 211011 [details] Minimal test case (UI file)
The following fix has been pushed: aa3d30e Fix a cornercase of menu parsing
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.