ThreadSanitizer data races
During build with -Db_sanitize=thread
, the following data race is reported:
/home/elliott/code/glib/tbuild/glib/gtester -k --quiet -o glib/tests/tmpsample.xml --test-arg=--gtester-selftest /home/elliott/code/glib/tbuild/glib/gtester
==================
WARNING: ThreadSanitizer: data race (pid=8663)
Write of size 4 at 0x7f12c3ded250 by main thread:
#0 g_unix_signal_handler ../glib/gmain.c:5404 (libglib-2.0.so.0+0x5ec1d)
#1 <null> <null> (libtsan.so.0+0x299e3)
#2 g_private_get_impl ../glib/gthread-posix.c:1031 (libglib-2.0.so.0+0xce9af)
#3 g_private_get ../glib/gthread-posix.c:1062 (libglib-2.0.so.0+0xce9af)
#4 thread_memory_from_self ../glib/gslice.c:506 (libglib-2.0.so.0+0x90d63)
#5 g_slice_free1 ../glib/gslice.c:1111 (libglib-2.0.so.0+0x90d63)
#6 g_list_remove ../glib/glist.c:524 (libglib-2.0.so.0+0x5d677)
#7 source_remove_from_context ../glib/gmain.c:1117 (libglib-2.0.so.0+0x5f9a0)
#8 g_source_unref_internal ../glib/gmain.c:2116 (libglib-2.0.so.0+0x5fa9f)
#9 g_main_dispatch ../glib/gmain.c:3219 (libglib-2.0.so.0+0x647b0)
#10 g_main_context_dispatch ../glib/gmain.c:3856 (libglib-2.0.so.0+0x647b0)
#11 g_main_context_iterate ../glib/gmain.c:3929 (libglib-2.0.so.0+0x64b7f)
#12 g_main_context_iteration ../glib/gmain.c:3990 (libglib-2.0.so.0+0x64c65)
#13 launch_test_binary ../glib/gtester.c:432 (gtester+0x40356f)
#14 launch_test ../glib/gtester.c:461 (gtester+0x40356f)
#15 main ../glib/gtester.c:708 (gtester+0x40356f)
Previous read of size 4 at 0x7f12c3ded250 by thread T1:
#0 glib_worker_main ../glib/gmain.c:5873 (libglib-2.0.so.0+0x64cd8)
#1 g_thread_proxy ../glib/gthread.c:778 (libglib-2.0.so.0+0xa041f)
#2 <null> <null> (libtsan.so.0+0x2a90d)
Location is global 'any_unix_signal_pending' of size 4 at 0x7f12c3ded250 (libglib-2.0.so.0+0x00000015b250)
Thread T1 'gmain' (tid=8667, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.0+0x2cfc2)
#1 g_system_thread_new ../glib/gthread-posix.c:1188 (libglib-2.0.so.0+0xced50)
#2 g_thread_new_internal ../glib/gthread.c:865 (libglib-2.0.so.0+0xa08e5)
#3 g_thread_new ../glib/gthread.c:821 (libglib-2.0.so.0+0xa096d)
#4 g_get_worker_context ../glib/gmain.c:5897 (libglib-2.0.so.0+0x65fea)
#5 ref_unix_signal_handler_unlocked ../glib/gmain.c:5233 (libglib-2.0.so.0+0x6603f)
#6 g_child_watch_source_new ../glib/gmain.c:5480 (libglib-2.0.so.0+0x6632c)
#7 g_child_watch_add_full ../glib/gmain.c:5544 (libglib-2.0.so.0+0x66403)
#8 launch_test_binary ../glib/gtester.c:419 (gtester+0x403546)
#9 launch_test ../glib/gtester.c:461 (gtester+0x403546)
#10 main ../glib/gtester.c:708 (gtester+0x403546)
SUMMARY: ThreadSanitizer: data race ../glib/gmain.c:5404 in g_unix_signal_handler
==================
ThreadSanitizer: reported 1 warnings
Note: this is not fixed by !383 (merged). Data races in gmain
seem to affect almost everything, like g-ir-scanner
, meaning you can't build with it enabled (though you can runtime-disable it for build and enable again for testing.)