Skip to content

Update tsan suppressions and fix a race in gc_start #13964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gc/default/default.c
Original file line number Diff line number Diff line change
Expand Up @@ -6316,9 +6316,6 @@ gc_start(rb_objspace_t *objspace, unsigned int reason)
{
unsigned int do_full_mark = !!(reason & GPR_FLAG_FULL_MARK);

/* reason may be clobbered, later, so keep set immediate_sweep here */
objspace->flags.immediate_sweep = !!(reason & GPR_FLAG_IMMEDIATE_SWEEP);

if (!rb_darray_size(objspace->heap_pages.sorted)) return TRUE; /* heap is not ready */
if (!(reason & GPR_FLAG_METHOD) && !ready_to_gc(objspace)) return TRUE; /* GC is not allowed */

Expand All @@ -6329,6 +6326,9 @@ gc_start(rb_objspace_t *objspace, unsigned int reason)
unsigned int lock_lev;
gc_enter(objspace, gc_enter_event_start, &lock_lev);

/* reason may be clobbered, later, so keep set immediate_sweep here */
objspace->flags.immediate_sweep = !!(reason & GPR_FLAG_IMMEDIATE_SWEEP);

#if RGENGC_CHECK_MODE >= 2
gc_verify_internal_consistency(objspace);
#endif
Expand Down
39 changes: 17 additions & 22 deletions misc/tsan_suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,16 @@ race_top:rb_ec_vm_lock_rec
race_top:vm_lock_enter
race_top:vm_locked

# Ractors
race:ractor_take
race:ractor_register_take
race:ractor_check_take_basket
race:ractor_selector__wait

# vm->ractor.sched.grq_cnt++
race_top:ractor_sched_enq
race_top:ractor_sched_deq

# Using VM lock instead of rb_native_mutex_unlock?
# Race between vm_remove_ractor writing ractor count and
# native_thread_check_and_create_shared reading it during thread creation.
# The write happens when a ractor thread exits, the read happens when
# checking if new shared threads need to be created.
race:vm_remove_ractor

# cr->sync.wait.wakeup_status
race_top:rb_ractor_sched_sleep

# th->sched.finished at end of co_start
race_top:rb_thread_sched_mark_zombies

Expand All @@ -62,9 +56,6 @@ race_top:thread_sched_wait_events
# At thread start
race_top:rb_ractor_set_current_ec_

# Possible deadlock between Ractor lock and UBF lock
deadlock:ractor_sleep_interrupt

# TSan reports a lock-order-inversion between thread_sched_lock_ and this lock.
# It's unclear if that can cause a deadlock since the lock is on self
deadlock:ractor_lock_self
Expand All @@ -76,16 +67,22 @@ deadlock:rb_ractor_sched_barrier_start
# RVALUE_AGE_SET manipulates flag bits on objects which may be accessed in Ractors
race_top:RVALUE_AGE_SET

# Inline caches
# Inline caches and call cache updates
# Multiple threads can race when updating shared call caches during method lookups
# and argument forwarding. These races involve reading/writing cd->cc fields.
race_top:vm_cc_call_set
race_top:vm_cc_class_check
race_top:vm_search_cc
race_top:vm_search_method_slowpath0
race_top:rb_vm_opt_getconstant_path
race_top:vm_ic_attr_index_set
race:vm_ic_update
race:vm_caller_setup_fwd_args

# Shapes have problems with RCLASS_MAX_IV_COUNT and RCLASS_VARIATION_COUNT
# which are probably benign
# Race in shape_get_next where multiple threads simultaneously access and modify
# RCLASS_MAX_IV_COUNT and RCLASS_VARIATION_COUNT fields in class objects.
# One thread reads the field while another thread calls RCLASS_SET_MAX_IV_COUNT.
# This happens during instance variable shape transitions in multi-threaded code.
race:shape_get_next

# Non-atomic reads/writes
Expand All @@ -99,16 +96,10 @@ race:rb_ec_cleanup
# timer thread
race:after_fork_ruby

# object_id races
race:object_id

# Sets objspace->flags.dont_incremental while writebarrier may be running
race_top:objspace_each_exec
race_top:objspace_each_objects_ensure

# Ractor autoload
race:rb_ractor_autoload_load

# Non-atomic lazy initialized static variable
race_top:rbimpl_intern_const

Expand All @@ -123,3 +114,7 @@ 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
race_top:rb_gc_impl_gc_disable
race_top:rb_gc_impl_gc_enable
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy