Skip to content

Commit 4044188

Browse files
committed
Fix load catch table write barrier
I tried fixing this in 521b2fc, but re-running wbcheck with the stricter WBCHECK_VERIFY_AFTER_WB, revealed that this write barrier was fired too early, before the object was actually written to the parent. This solves the issue by writing the table to the parent immediately (and using calloc so that we don't mark random garbage).
1 parent fcf2c3b commit 4044188

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

compile.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13296,12 +13296,13 @@ ibf_dump_catch_table(struct ibf_dump *dump, const rb_iseq_t *iseq)
1329613296
}
1329713297
}
1329813298

13299-
static struct iseq_catch_table *
13299+
static void
1330013300
ibf_load_catch_table(const struct ibf_load *load, ibf_offset_t catch_table_offset, unsigned int size, const rb_iseq_t *parent_iseq)
1330113301
{
1330213302
if (size) {
13303-
struct iseq_catch_table *table = ruby_xmalloc(iseq_catch_table_bytes(size));
13303+
struct iseq_catch_table *table = ruby_xcalloc(1, iseq_catch_table_bytes(size));
1330413304
table->size = size;
13305+
ISEQ_BODY(parent_iseq)->catch_table = table;
1330513306

1330613307
ibf_offset_t reading_pos = catch_table_offset;
1330713308

@@ -13317,10 +13318,9 @@ ibf_load_catch_table(const struct ibf_load *load, ibf_offset_t catch_table_offse
1331713318
rb_iseq_t *catch_iseq = (rb_iseq_t *)ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)iseq_index);
1331813319
RB_OBJ_WRITE(parent_iseq, UNALIGNED_MEMBER_PTR(&table->entries[i], iseq), catch_iseq);
1331913320
}
13320-
return table;
1332113321
}
1332213322
else {
13323-
return NULL;
13323+
ISEQ_BODY(parent_iseq)->catch_table = NULL;
1332413324
}
1332513325
}
1332613326

@@ -13833,7 +13833,8 @@ ibf_load_iseq_each(struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t offset)
1383313833
load_body->insns_info.body = ibf_load_insns_info_body(load, insns_info_body_offset, insns_info_size);
1383413834
load_body->insns_info.positions = ibf_load_insns_info_positions(load, insns_info_positions_offset, insns_info_size);
1383513835
load_body->local_table = ibf_load_local_table(load, local_table_offset, local_table_size);
13836-
load_body->catch_table = ibf_load_catch_table(load, catch_table_offset, catch_table_size, iseq);
13836+
ibf_load_catch_table(load, catch_table_offset, catch_table_size, iseq);
13837+
1383713838
const rb_iseq_t *parent_iseq = ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)parent_iseq_index);
1383813839
const rb_iseq_t *local_iseq = ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)local_iseq_index);
1383913840
const rb_iseq_t *mandatory_only_iseq = ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)mandatory_only_iseq_index);

0 commit comments

Comments
 (0)