Commit 4d162a3d
4d162a3df945Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
fix(analyze): skip @multi_const_inits for non-constant top-level multi-write
Top-level y, z = call_returning_pair segfaulted: every MultiWriteNode
got pushed into @multi_const_inits regardless of whether any target was
a constant, so codegen's pre-body init loop planted a bogus
_t = call(lv_a, lv_b); emit before the locals it reads from had been
assigned. With both args still NULL the inlined method body deref'd
NULL and crashed.
Skip the push when no target is a constant; the real destructure runs later through compile_multi_write and lands the correctly GC-rooted call.
Fixes #630.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 4d162a3df945
- Parent
- d17bf68f7f81
spinel_analyze.rbmodifiedView file
def collect_scoped_multi_const(scope_name, nid) targets = parse_id_list(@nd_targets[nid]) val_id = @nd_expression[nid] has_const_target = 0 ti = 0 while ti < targets.length tid = targets[ti] if @nd_type[tid] == "ConstantTargetNode" has_const_target = 1 cname = @nd_name[tid] if scope_name != "" cname = scope_name + "_" + cname end end # Record the multi-write as a single deferred init: the RHS is # evaluated once and each constant takes one element. # evaluated once and each constant takes one element. Skip when # no target is a constant (top-level `y, z = call_returning_pair` # would otherwise plant a bogus pre-body emit that fires before # the locals it reads from are assigned, #630). if has_const_target == 0 return end if @multi_const_inits == nil @multi_const_inits = "".split(",") endtest/destructure_typed_ptr_array_return.expectedaddedView file
Loading diff…
test/destructure_typed_ptr_array_return.rbaddedView file
Loading diff…