Restore thread sanitizer CI job
The thread sanitizer job currently produces what may be false positives, but with not enough information to debug them. For example, the error that was blocking !683 (merged) for a long time:
(click to view thread sanitizer errors)
WARNING: ThreadSanitizer: data race (pid=2950)
Write of size 8 at 0x7b0800011e20 by thread T10:
#0 free <null> (libtsan.so.0+0x37a28)
#1 g_free <null> (libglib-2.0.so.0+0x5a24c)
Previous write of size 8 at 0x7b0800011e20 by main thread:
#0 malloc <null> (libtsan.so.0+0x32919)
#1 g_malloc <null> (libglib-2.0.so.0+0x5d938)
#2 Gjs::Function::call(JSContext*, unsigned int, JS::Value*) ../gi/function.cpp:1092 (libgjs.so.0+0x798d5)
#3 CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) /root/mozjs/js/src/vm/Interpreter.cpp:493 (libmozjs-78.so+0x1d42a1)
#4 GjsContextPrivate::eval(char const*, long, char const*, int*, _GError**) ../gjs/context.cpp:1270 (libgjs.so.0+0xef776)
#5 gjs_context_eval ../gjs/context.cpp:1192 (libgjs.so.0+0xeefdb)
#6 define_argv_and_eval_script(_GjsContext*, int, char* const*, char const*, unsigned long, char const*) ../gjs/console.cpp:191 (gjs-console+0x4031a9)
#7 main ../gjs/console.cpp:384 (gjs-console+0x403efe)
Thread T10 'gmain' (tid=2962, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.0+0x5bf45)
#1 g_system_thread_new ../glib/gthread-posix.c:1323 (libglib-2.0.so.0+0x85140)
#2 g_thread_new_internal ../glib/gthread.c:931 (libglib-2.0.so.0+0x85140)
#3 Gjs::Function::call(JSContext*, unsigned int, JS::Value*) ../gi/function.cpp:1092 (libgjs.so.0+0x798d5)
#4 CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) /root/mozjs/js/src/vm/Interpreter.cpp:493 (libmozjs-78.so+0x1d42a1)
#5 GjsContextPrivate::eval(char const*, long, char const*, int*, _GError**) ../gjs/context.cpp:1270 (libgjs.so.0+0xef776)
#6 gjs_context_eval ../gjs/context.cpp:1192 (libgjs.so.0+0xeefdb)
#7 define_argv_and_eval_script(_GjsContext*, int, char* const*, char const*, unsigned long, char const*) ../gjs/console.cpp:191 (gjs-console+0x4031a9)
#8 main ../gjs/console.cpp:384 (gjs-console+0x403efe)
SUMMARY: ThreadSanitizer: data race (/lib64/libtsan.so.0+0x37a28) in free
==================
==================
WARNING: ThreadSanitizer: data race (pid=2950)
Write of size 8 at 0x7b1c00007700 by thread T10:
#0 free <null> (libtsan.so.0+0x37a28)
#1 g_free <null> (libglib-2.0.so.0+0x5a24c)
Previous write of size 8 at 0x7b1c00007700 by main thread:
#0 calloc <null> (libtsan.so.0+0x32b3e)
#1 g_malloc0 <null> (libglib-2.0.so.0+0x5de60)
#2 Gjs::Function::call(JSContext*, unsigned int, JS::Value*) ../gi/function.cpp:1092 (libgjs.so.0+0x798d5)
#3 CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) /root/mozjs/js/src/vm/Interpreter.cpp:493 (libmozjs-78.so+0x1d42a1)
#4 GjsContextPrivate::eval(char const*, long, char const*, int*, _GError**) ../gjs/context.cpp:1270 (libgjs.so.0+0xef776)
#5 gjs_context_eval ../gjs/context.cpp:1192 (libgjs.so.0+0xeefdb)
#6 define_argv_and_eval_script(_GjsContext*, int, char* const*, char const*, unsigned long, char const*) ../gjs/console.cpp:191 (gjs-console+0x4031a9)
#7 main ../gjs/console.cpp:384 (gjs-console+0x403efe)
Thread T10 'gmain' (tid=2962, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.0+0x5bf45)
#1 g_system_thread_new ../glib/gthread-posix.c:1323 (libglib-2.0.so.0+0x85140)
#2 g_thread_new_internal ../glib/gthread.c:931 (libglib-2.0.so.0+0x85140)
#3 Gjs::Function::call(JSContext*, unsigned int, JS::Value*) ../gi/function.cpp:1092 (libgjs.so.0+0x798d5)
#4 CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) /root/mozjs/js/src/vm/Interpreter.cpp:493 (libmozjs-78.so+0x1d42a1)
#5 GjsContextPrivate::eval(char const*, long, char const*, int*, _GError**) ../gjs/context.cpp:1270 (libgjs.so.0+0xef776)
#6 gjs_context_eval ../gjs/context.cpp:1192 (libgjs.so.0+0xeefdb)
#7 define_argv_and_eval_script(_GjsContext*, int, char* const*, char const*, unsigned long, char const*) ../gjs/console.cpp:191 (gjs-console+0x4031a9)
#8 main ../gjs/console.cpp:384 (gjs-console+0x403efe)
SUMMARY: ThreadSanitizer: data race (/lib64/libtsan.so.0+0x37a28) in free
==================
ThreadSanitizer: reported 2 warnings
Personally I was never able to reproduce failures from the CI locally, I always got different (and more) failures when running TSAN locally. So I think in order to restore the thread sanitizer job we should meet two conditions:
- Stable results: we should not have too many false positives. (This probably means supporting TSAN in GLib/GIO) (See #408)
- Ability to reproduce locally: there should be documentation on how to set up a TSAN build on your local machine in order to get the same results as on CI, so that you can debug the failures.
Edited by Philip Chimento