mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-16 12:28:48 +02:00
gio/tests/gdbus-export: Ensure we call all the callbacks on return
Ensure we don't do an user-after-free access, as reported by ASAN: ==3704==ERROR: AddressSanitizer: stack-use-after-return on address 0x70a58f8631c0 at pc 0x000000405144 bp 0x7fffff62c7a0 sp 0x7fffff62c798 READ of size 4 at 0x70a58f8631c0 thread T0 #0 0x405143 in on_object_unregistered ../../GNOME/glib/gio/tests/gdbus-export.c:597 #1 0x70a592e858d8 in call_destroy_notify_data_in_idle ../../GNOME/glib/gio/gdbusconnection.c:244 #2 0x70a5940016a4 in g_idle_dispatch ../../GNOME/glib/glib/gmain.c:6221 #3 0x70a59401095b in g_main_dispatch ../../GNOME/glib/glib/gmain.c:3348 #4 0x70a59401095b in g_main_context_dispatch_unlocked ../../GNOME/glib/glib/gmain.c:4197 #5 0x70a59401ba17 in g_main_context_iterate_unlocked ../../GNOME/glib/glib/gmain.c:4262 #6 0x70a59401cc73 in g_main_context_iteration ../../GNOME/glib/glib/gmain.c:4327 #7 0x405658 in test_threaded_unregistration_iteration ../../GNOME/glib/gio/tests/gdbus-export.c:1878 #8 0x405658 in test_threaded_unregistration ../../GNOME/glib/gio/tests/gdbus-export.c:1952 #9 0x70a5940dfb04 in test_case_run ../../GNOME/glib/glib/gtestutils.c:2988 #10 0x70a5940dfb04 in g_test_run_suite_internal ../../GNOME/glib/glib/gtestutils.c:3090 #11 0x70a5940df893 in g_test_run_suite_internal ../../GNOME/glib/glib/gtestutils.c:3109 #12 0x70a5940df893 in g_test_run_suite_internal ../../GNOME/glib/glib/gtestutils.c:3109 #13 0x70a5940e0bc9 in g_test_run_suite ../../GNOME/glib/glib/gtestutils.c:3189 #14 0x70a5940e0d1f in g_test_run ../../GNOME/glib/glib/gtestutils.c:2275 #15 0x40eb72 in session_bus_run ../../GNOME/glib/gio/tests/gdbus-sessionbus.c:69 #16 0x403a2c in main ../../GNOME/glib/gio/tests/gdbus-export.c:1990 #17 0x70a591d9f149 in __libc_start_call_main (/lib64/libc.so.6+0x28149) (BuildId: 0d710e9d9dc10c500b8119c85da75004183618e2) #18 0x70a591d9f20a in __libc_start_main_impl (/lib64/libc.so.6+0x2820a) (BuildId: 0d710e9d9dc10c500b8119c85da75004183618e2) #19 0x403b44 in _start (/tmp/_build/gio/tests/gdbus-export+0x403b44) (BuildId: f6312e919c3d94e4c49270b0dfc5c870e1ba550b) Address 0x70a58f8631c0 is located in stack of thread T0 at offset 192 in frame #0 0x40525f in test_threaded_unregistration ../../GNOME/glib/gio/tests/gdbus-export.c:1936 This frame has 7 object(s): [32, 40) 'local_error' (line 1835) [64, 72) 'unregister_thread' (line 1836) [96, 104) 'value' (line 1838) [128, 136) 'value_str' (line 1839) [160, 168) 'call_result' (line 1840) [192, 204) 'object_registration_data' (line 1834) <== Memory access at offset 192 is inside this variable [224, 240) 'data' (line 1833)
This commit is contained in:
parent
6ed59a6f40
commit
ea52feb658
@ -1928,6 +1928,17 @@ test_threaded_unregistration_iteration (gboolean subtree)
|
||||
g_clear_object (&call_result);
|
||||
g_clear_object (&data.connection);
|
||||
|
||||
/* We defer quitting to a G_PRIORITY_DEFAULT_IDLE function so other queued
|
||||
* signal callbacks have a chance to run first.
|
||||
* In particular we want to ensure that all calls to on_object_unregistered()
|
||||
* are delivered here before we end this function, so that there won't be any
|
||||
* invalid stack access.
|
||||
* They get dispatched with a higher priority (G_PRIORITY_DEFAULT), so as
|
||||
* long as the queue is non-empty g_main_loop_quit won't run
|
||||
*/
|
||||
g_idle_add_once ((GSourceOnceFunc) g_main_loop_quit, loop);
|
||||
g_main_loop_run (loop);
|
||||
|
||||
return unregistration_was_first;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user