Disable TSAN for rb_gc_mark_machine_context

Previously this was listed as a suppression, but we actually want this
permanently unsanitized. This should be faster and more reliable since
TASN won't have to match against symbolicated backtraces.
This commit is contained in:
John Hawthorn 2025-07-18 16:06:17 -07:00
parent 3ad2019259
commit 7f25b8f5fb
3 changed files with 11 additions and 4 deletions

View file

@ -1372,6 +1372,7 @@ AC_CHECK_HEADERS(process.h)
AC_CHECK_HEADERS(pwd.h) AC_CHECK_HEADERS(pwd.h)
AC_CHECK_HEADERS(sanitizer/asan_interface.h) AC_CHECK_HEADERS(sanitizer/asan_interface.h)
AC_CHECK_HEADERS(sanitizer/msan_interface.h) AC_CHECK_HEADERS(sanitizer/msan_interface.h)
AC_CHECK_HEADERS(sanitizer/tsan_interface.h)
AC_CHECK_HEADERS(setjmpex.h) AC_CHECK_HEADERS(setjmpex.h)
AC_CHECK_HEADERS(stdalign.h) AC_CHECK_HEADERS(stdalign.h)
AC_CHECK_HEADERS(stdio.h) AC_CHECK_HEADERS(stdio.h)

View file

@ -29,6 +29,13 @@
# endif # endif
#endif #endif
#ifdef HAVE_SANITIZER_TSAN_INTERFACE_H
# if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)
# define RUBY_TSAN_ENABLED
# include <sanitizer/tsan_interface.h>
# endif
#endif
#include "ruby/internal/stdbool.h" /* for bool */ #include "ruby/internal/stdbool.h" /* for bool */
#include "ruby/ruby.h" /* for VALUE */ #include "ruby/ruby.h" /* for VALUE */
@ -42,6 +49,9 @@
#elif defined(RUBY_MSAN_ENABLED) #elif defined(RUBY_MSAN_ENABLED)
# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
__attribute__((__no_sanitize__("memory"), __noinline__)) x __attribute__((__no_sanitize__("memory"), __noinline__)) x
#elif defined(RUBY_TSAN_ENABLED)
# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
__attribute__((__no_sanitize__("thread"), __noinline__)) x
#elif defined(NO_SANITIZE_ADDRESS) #elif defined(NO_SANITIZE_ADDRESS)
# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
NO_SANITIZE_ADDRESS(NOINLINE(x)) NO_SANITIZE_ADDRESS(NOINLINE(x))

View file

@ -104,10 +104,6 @@ race_top:encoded_iseq_trace_instrument
race:rb_iseq_trace_set_all race:rb_iseq_trace_set_all
race:rb_tracepoint_enable race:rb_tracepoint_enable
# We walk the machine stack looking for markable objects, a thread with the GVL
# released could by mutating the stack with non-Ruby-objects
race:rb_gc_mark_machine_context
# GC enable/disable flag modifications race with object allocation flag reads # GC enable/disable flag modifications race with object allocation flag reads
race_top:rb_gc_impl_gc_disable race_top:rb_gc_impl_gc_disable
race_top:rb_gc_impl_gc_enable race_top:rb_gc_impl_gc_enable