Commit 9eac4813
9eac48131d24Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 5 files · +4 added · ~1 modified
Description
fix(codegen): map on poly / nullable typed-array recv emits the loop
Two paths in compile_map_expr that fell through to the catch-all "0" return, leaking sp_StrArray * _tN = 0; NULL through to the downstream .join:
rt == "poly": receiver is sp_RbVal (typical when the parameter has a= nildefault —def f(arr = nil); arr.map { ... }.join end). Added a runtime tag-dispatch arm that peekscls_idand reads each element via the matching sp_PolyArray_get / sp_IntArray_get / sp_StrArray_get / sp_FloatArray_get. Block param is sp_RbVal; accumulator picks its variant from the block's last-expression static type (string -> StrArray, int -> IntArray, float -> FloatArray, otherwise PolyArray).rt == "int_array?"/str_array?/ etc.: the nullable pointer types weren't matched by the per-container arms. Strip the?suffix at the top of the function so the base-type dispatch reaches the existing arms.
Reporter (#654) hit this on runtime/ruby/action_view/view _helpers.rb#javascript_importmap_tags(pins = nil, ...) where
pins.map { ... }.join(",\n") segfaulted in the real-blog AOT
binary.
Closes #654.
Default test 632/0/0 (+1 regression test poly_recv_map_join). Optcarrot wrap checksum 59662 unchanged.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 9eac48131d24
- Parent
- ad76ddb15068
array_new_block_typed_containeraddedView file
Binary summary diff
@@ -1,0 +1,13 @@
+Format: ELF binary
+Class: ELF64
+Endianness: little
+ABI: System V
+Type: shared object / PIE
+Architecture: x86-64
+Entry point: 0x1d40
+Program headers: 13
+Program header offset: 0x40
+Program header size: 56
+Section headers: 31
+Flags: 0x0
+Sections: .interp, .note.gnu.property, .note.gnu.build-id, .note.ABI-tag, .gnu.hash, .dynsym, .dynstr, .gnu.version, .gnu.version_r, .rela.dyn, .rela.plt, .init, .plt, .plt.got, .plt.sec, .text, .fini, .rodata, .eh_frame_hdr, .eh_frame, .init_array, .fini_array, .dynamic, .got, .data, .bss, .comment, .symtab, .strtab, .shstrtab
file_write_poly_argaddedView file
Loading diff…
spinel_codegen.rbmodifiedView file
Loading diff…
test/poly_recv_map_join.rbaddedView file
Loading diff…
test/poly_recv_map_join.rb.expectedaddedView file
Loading diff…