Commit 1bb15bd
add VM Lock around
Without a VM Lock, there's an unlocked `rb_id_table_delete` for the
class's const_tbl which can cause problems. Example:
```ruby
class C
CONSTANT = 3
end
$VERBOSE = nil
rs = []
100.times do
rs << Ractor.new do
10_000.times do
if defined?(C::CONSTANT)
C.send(:remove_const, :CONSTANT) rescue NameError
else
C.send(:const_set, :CONSTANT, 3)
end
end
end
end
while rs.any?
r, obj = Ractor.select(*rs)
rs.delete(r)
end
```
Without lock:
../ruby-release/test.rb:14: [BUG] Segmentation fault at 0x0000000000000001
-- Control frame information -----------------------------------------------
miniruby(82790,0x16f49f000) malloc: *** error for object 0x600000f880a0: pointer being freed was not allocated
miniruby(82790,0x16f49f000) malloc: *** set a breakpoint in malloc_error_break to debugrb_const_remove operations (Module#remove_const)1 parent b6d0961 commit 1bb15bd
1 file changed
Lines changed: 19 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3717 | 3717 | | |
3718 | 3718 | | |
3719 | 3719 | | |
3720 | | - | |
3721 | | - | |
3722 | | - | |
3723 | | - | |
3724 | | - | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
3725 | 3726 | | |
3726 | | - | |
3727 | | - | |
| 3727 | + | |
| 3728 | + | |
3728 | 3729 | | |
3729 | | - | |
3730 | | - | |
| 3730 | + | |
| 3731 | + | |
3731 | 3732 | | |
3732 | | - | |
| 3733 | + | |
3733 | 3734 | | |
3734 | | - | |
3735 | | - | |
3736 | | - | |
3737 | | - | |
| 3735 | + | |
| 3736 | + | |
| 3737 | + | |
| 3738 | + | |
3738 | 3739 | | |
3739 | | - | |
3740 | | - | |
| 3740 | + | |
| 3741 | + | |
| 3742 | + | |
| 3743 | + | |
3741 | 3744 | | |
3742 | | - | |
3743 | 3745 | | |
3744 | 3746 | | |
3745 | 3747 | | |
| |||
0 commit comments