Commit f062dbb
committed
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 ae04538 commit f062dbb
1 file changed
+19
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3671 | 3671 | | |
3672 | 3672 | | |
3673 | 3673 | | |
3674 | | - | |
3675 | | - | |
3676 | | - | |
3677 | | - | |
3678 | | - | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
3679 | 3680 | | |
3680 | | - | |
3681 | | - | |
| 3681 | + | |
| 3682 | + | |
3682 | 3683 | | |
3683 | | - | |
3684 | | - | |
| 3684 | + | |
| 3685 | + | |
3685 | 3686 | | |
3686 | | - | |
| 3687 | + | |
3687 | 3688 | | |
3688 | | - | |
3689 | | - | |
3690 | | - | |
3691 | | - | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
3692 | 3693 | | |
3693 | | - | |
3694 | | - | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
3695 | 3698 | | |
3696 | | - | |
3697 | 3699 | | |
3698 | 3700 | | |
3699 | 3701 | | |
| |||
0 commit comments