Commit fcf2c3b
Fix write barriers in rb_hash_add_new_element
The write barriers must be run after the st_update callback returns,
as the objects are not on the object until then and there may be
allocation when there is a new object inserted.
This is hard to reproduce, and I haven't seen an actual crash due to it,
but it is detected by wbcheck
RUBY_GC_LIBRARY=wbcheck WBCHECK_VERIFY_AFTER_WB=1 ./miniruby -e '("a".."zz").uniq.to_a'
WBCHECK ERROR: Missed write barrier detected!
Parent object: 0x720db01f99c0 (wb_protected: true)
rb_obj_info_dump: 0x0000720db01f99c0 T_HASH/[S] 18
Reference counts - snapshot: 32, writebarrier: 2, current: 36, missed: 2
Missing reference to: 0x716db02e3450
rb_obj_info_dump: 0x0000716db02e3450 T_STRING/String len: 1, capa: 15 "q"
Missing reference to: 0x716db02e3450
rb_obj_info_dump: 0x0000716db02e3450 T_STRING/String len: 1, capa: 15 "q"
A part of why this is hard to reproduce and it's unlikely to crash is
that the insertion only rarely allocates.
Co-authored-by: Luke Gruber <[email protected]>1 parent c351c3d commit fcf2c3b
1 file changed
+15
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5073 | 5073 | | |
5074 | 5074 | | |
5075 | 5075 | | |
5076 | | - | |
5077 | 5076 | | |
5078 | | - | |
5079 | | - | |
| 5077 | + | |
5080 | 5078 | | |
5081 | 5079 | | |
5082 | 5080 | | |
| |||
5088 | 5086 | | |
5089 | 5087 | | |
5090 | 5088 | | |
5091 | | - | |
5092 | | - | |
5093 | | - | |
5094 | | - | |
| 5089 | + | |
5095 | 5090 | | |
5096 | 5091 | | |
5097 | | - | |
5098 | | - | |
5099 | | - | |
| 5092 | + | |
| 5093 | + | |
| 5094 | + | |
5100 | 5095 | | |
5101 | | - | |
5102 | 5096 | | |
5103 | 5097 | | |
5104 | | - | |
5105 | | - | |
5106 | | - | |
| 5098 | + | |
| 5099 | + | |
| 5100 | + | |
| 5101 | + | |
| 5102 | + | |
| 5103 | + | |
| 5104 | + | |
| 5105 | + | |
| 5106 | + | |
| 5107 | + | |
5107 | 5108 | | |
5108 | 5109 | | |
5109 | 5110 | | |
| |||
0 commit comments