mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Fix TSAN data race in gc_start
objspace->flags.immediate_sweep shares the same word as objspace->flags.during_incremental_marking. So in gc_start we need to assign it after gc_enter() so that we hold the VM lock and have issued a barrier, as rb_gc_impl_writebarrier is reading objspace->flags.during_incremental_marking.
This commit is contained in:
parent
a1403fb7cb
commit
973e6770d5
1 changed files with 3 additions and 3 deletions
|
@ -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 */
|
||||
|
||||
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue