Bug #2397
closedCrash on cancelling meeting
0%
Description
I cancelled a meeting that had been open a long time
I'm running my own build, with the fix for #2371 applied (manually, before it was merged)
commit d4f019c3e3857ca9d46263e02524ed43d9ce47fe
$ patch -p1 < ~/Downloads/0080-gtk4-x-Fix-diplodlg-closing-memory-handling.patch
Seems like it's still related?
1: Gtk: gtk_css_node_insert_after: assertion 'previous_sibling NULL || previous_sibling->parent parent' failed
3: Backtrace:
3: 0: /home/andrew/apps/lib/x86_64-linux-gnu/libfreeciv.so(backtrace_print+0x25) [0x7f3c1016aff9]
3: 1: /home/andrew/apps/lib/x86_64-linux-gnu/libfreeciv.so(+0x16afd1) [0x7f3c1016afd1]
3: 2: /home/andrew/apps/lib/x86_64-linux-gnu/libfreeciv.so(vdo_log+0xc2) [0x7f3c10176ef0]
3: 3: /home/andrew/apps/lib/x86_64-linux-gnu/libfreeciv.so(do_log+0xd0) [0x7f3c101773ac]
3: 4: /home/andrew/apps/bin/freeciv-gtk4(+0x8473e) [0x55dd014e673e]
3: 5: /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_logv+0x21b) [0x7f3c0efc826b]
3: 6: /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_log+0x93) [0x7f3c0efc85c3]
3: 7: /lib/x86_64-linux-gnu/libgtk-4.so.1(+0x2cb1c0) [0x7f3c0f6cb1c0]
3: 8: /lib/x86_64-linux-gnu/libgtk-4.so.1(+0x41188b) [0x7f3c0f81188b]
3: 9: /lib/x86_64-linux-gnu/libgtk-4.so.1(+0x420ca6) [0x7f3c0f820ca6]
3: 10: /lib/x86_64-linux-gnu/libgtk-4.so.1(+0xddf1b) [0x7f3c0f4ddf1b]
3: 11: /lib/x86_64-linux-gnu/libgobject-2.0.so.0(+0x17b81) [0x7f3c0ff86b81]
3: 12: /lib/x86_64-linux-gnu/libgobject-2.0.so.0(+0x2cb33) [0x7f3c0ff9bb33]
3: 13: /lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit_valist+0x36) [0x7f3c0ffa25a6]
3: 14: /lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit+0x93) [0x7f3c0ffa2663]
3: 15: /lib/x86_64-linux-gnu/libgtk-4.so.1(+0x1685e1) [0x7f3c0f5685e1]
3: 16: /lib/x86_64-linux-gnu/libgtk-4.so.1(+0x1675ae) [0x7f3c0f5675ae]
3: 17: /lib/x86_64-linux-gnu/libgtk-4.so.1(+0x2c089c) [0x7f3c0f6c089c]
3: 18: /lib/x86_64-linux-gnu/libgtk-4.so.1(+0x1dd83e) [0x7f3c0f5dd83e]
3: 19: /lib/x86_64-linux-gnu/libgtk-4.so.1(+0x1ddda3) [0x7f3c0f5ddda3]
3: 20: /lib/x86_64-linux-gnu/libgtk-4.so.1(+0x468762) [0x7f3c0f868762]
3: 21: /lib/x86_64-linux-gnu/libgtk-4.so.1(+0x50115d) [0x7f3c0f90115d]
3: 22: /lib/x86_64-linux-gnu/libgobject-2.0.so.0(+0x17b81) [0x7f3c0ff86b81]
3: 23: /lib/x86_64-linux-gnu/libgobject-2.0.so.0(+0x2cb33) [0x7f3c0ff9bb33]
3: 24: /lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit_valist+0x36) [0x7f3c0ffa25a6]
3: 25: /lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit+0x93) [0x7f3c0ffa2663]
3: 26: /lib/x86_64-linux-gnu/libgtk-4.so.1(+0x50510b) [0x7f3c0f90510b]
3: 27: /lib/x86_64-linux-gnu/libgtk-4.so.1(+0x47f52e) [0x7f3c0f87f52e]
3: 28: /lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x5c485) [0x7f3c0efbd485]
3: 29: /lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x5e6b7) [0x7f3c0efbf6b7]
3: 30: /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x30) [0x7f3c0efbfe20]
3: 31: /lib/x86_64-linux-gnu/libgio-2.0.so.0(g_application_run+0x1ed) [0x7f3c0f1a4f1d]
3: 32: /home/andrew/apps/bin/freeciv-gtk4(+0x852c5) [0x55dd014e72c5]
3: 33: /home/andrew/apps/bin/freeciv-gtk4(+0xd544f) [0x55dd0153744f]
3: 34: /home/andrew/apps/bin/freeciv-gtk4(main+0x25) [0x55dd014e68e0]
3: 35: /lib/x86_64-linux-gnu/libc.so.6(+0x29ca8) [0x7f3c0eab9ca8]
3: 36: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85) [0x7f3c0eab9d65]
3: 37: /home/andrew/apps/bin/freeciv-gtk4(+0x3f5d1) [0x55dd014a15d1]
malloc(): unsorted double linked list corrupted
Aborted
Files
Updated by Marko Lindqvist about 1 month ago
Do you recall if it was the only open diplomacy meeting, or was there still other meetings open?
Updated by Marko Lindqvist about 1 month ago
- Related to Feature #2398: gtk4: Assert notebook page number to remove added
Updated by Andrew McGuinness about 1 month ago
It was the only one at the time I closed it.
Updated by Marko Lindqvist 17 days ago
One suspect is that gui_dialog_destroy() first removes notebook page, and only then removes the signal handler. I'm not sure the signal handler acts sane when removing the last page.
Updated by Sweet Tea Dorminy 2 days ago
- File 0001-gtk4-Do-not-touch-gui_dialog-after-destroying-its-S3_x.patch 0001-gtk4-Do-not-touch-gui_dialog-after-destroying-its-S3_x.patch added
- File 0001-gtk4-x-Do-not-touch-gui_dialog-after-destroying-its-.patch 0001-gtk4-x-Do-not-touch-gui_dialog-after-destroying-its-.patch added
I think this is a use-after-free in gui_dialog_destroy(), from the #2371 change.
gtk_notebook_remove_page() drops the last reference to dlg->grid, so gui_dialog_destroy_handler() runs and frees dlg before the call returns (checked with a small gtk 4.23 test program: the page's "destroy" handler runs inside remove_page). gui_dialog_destroy() then reads dlg->v.tab.notebook / handler_id from freed memory, and does *(dlg->source) = NULL through a freed pointer.
Usually the UAF is fine, stale values are still there and nothing shows. When the chunk has been reused, which is likely when the whole Diplomacy main tab goes with the last meeting, that write lands somewhere random. The window case has the same pattern (dlg->v.window = NULL after gtk_window_destroy()).
The switch-page handler itself looks harmless: when it runs during the removal, page_num of the removed grid is -1.
Attached patch clears *source and disconnects the handler first, then removes the page or destroys the window, and does not touch dlg after that. It should also be fine if the destroy is deferred, as in #2371. Main and S3_x versions; asan flags this pre-patch, and not after-patch going through the cancel meeting dialogue.
Updated by Sweet Tea Dorminy 1 day ago
Oh I see #2447 fix turns out to have the same code change. Guess we can close this one as a duplicate :D
Updated by Marko Lindqvist 1 day ago
- Category set to gtk4-client
- Status changed from New to Closed
- Assignee set to Marko Lindqvist