Project

General

Profile

Actions

Bug #21439

closed

Crash with PM_SPLAT_NODE compiler error (Prism)

Added by bendrissou (Bachir Bendrissou) 3 days ago. Updated 2 days ago.

Status:
Closed
Assignee:
Target version:
-
[ruby-core:122519]

Description

Hi Ruby team,

I'm encountering a crash when using a splat (*) on the left-hand side of a for loop in the latest Ruby build from master. The error occurs during compilation, and seems related to Prism’s handling of PM_SPLAT_NODE.

Input

The following minimal script crashes:

for *y in [4, 5]
  p y
end

Expected Output

[4]
[5]

Actual Output

bug-1.rb: [BUG] Unexpected node type for index in for node: PM_SPLAT_NODE
ruby 3.5.0dev (2025-06-11T18:07:43Z master 970813d982) +PRISM [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0001 p:0000 s:0003 E:000720 DUMMY  [FINISH]


-- Threading information ---------------------------------------------------
Total ractor count: 1
Ruby thread count for this ractor: 1

-- C level backtrace information -------------------------------------------
/lib/x86_64-linux-gnu/libasan.so.5(__interceptor_backtrace+0x40) [0x7f13b793bd40] ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4022
/home/ruby/build/ruby(rb_print_backtrace+0x11) [0x558d33041da9] ../vm_dump.c:843
/home/ruby/build/ruby(rb_vm_bugreport) ../vm_dump.c:1175
/home/ruby/build/ruby(rb_bug_without_die_internal+0xc5) [0x558d32704b21] ../error.c:1097
/home/ruby/build/ruby(rb_bug) ../error.c:1115
/home/ruby/build/ruby(pm_compile_for_node_index+0x117) [0x558d32ee742c] ../prism_compile.c:5340
/home/ruby/build/ruby(pm_compile_scope_node) ../prism_compile.c:6911
/home/ruby/build/ruby(pm_compile_node+0x1b50) [0x558d32e88490] ../prism_compile.c:10201
/home/ruby/build/ruby(pm_iseq_compile_node+0x437) [0x558d32eea437] ../prism_compile.c:10512
/home/ruby/build/ruby(pm_iseq_new_with_opt_try+0x3e) [0x558d32824c5e] ../iseq.c:1050
/home/ruby/build/ruby(rb_protect+0x30f) [0x558d327183ff] ../eval.c:1059
/home/ruby/build/ruby(pm_iseq_new_with_opt+0x482) [0x558d32832c12] ../iseq.c:1103
/home/ruby/build/ruby(pm_new_child_iseq+0x19a) [0x558d32dbdc7a] ../prism_compile.c:1261
/home/ruby/build/ruby(pm_compile_node+0x15296) [0x558d32e9bbd6] ../prism_compile.c:9199
/home/ruby/build/ruby(pm_compile_node+0x529d) [0x558d32e8bbdd] ../prism_compile.c:10330
/home/ruby/build/ruby(pm_compile_scope_node+0x3f42) [0x558d32ee3382] ../prism_compile.c:7012
/home/ruby/build/ruby(pm_compile_node+0x1b50) [0x558d32e88490] ../prism_compile.c:10201
/home/ruby/build/ruby(APPEND_LIST+0x0) [0x558d32eea2a4] ../prism_compile.c:10502
/home/ruby/build/ruby(pm_iseq_compile_node) ../prism_compile.c:10506
/home/ruby/build/ruby(pm_iseq_new_with_opt_try+0x3e) [0x558d32824c5e] ../iseq.c:1050
/home/ruby/build/ruby(rb_protect+0x30f) [0x558d327183ff] ../eval.c:1059
/home/ruby/build/ruby(pm_iseq_new_with_opt+0x482) [0x558d32832c12] ../iseq.c:1103
/home/ruby/build/ruby(pm_iseq_new_main+0xbc) [0x558d328332ac] ../iseq.c:951
/home/ruby/build/ruby(process_options+0x2d32) [0x558d329d2b12] ../ruby.c:2641
/home/ruby/build/ruby(ruby_process_options+0x3f0) [0x558d329d5290] ../ruby.c:3199
/home/ruby/build/ruby(ruby_options+0x2a7) [0x558d32715407] ../eval.c:117
/home/ruby/build/ruby(rb_main+0x19) [0x558d327067ff] ../main.c:42
/home/ruby/build/ruby(main) ../main.c:62
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f13b7487083]
/home/ruby/build/ruby(_start) [0x558d32707dce]

-- Other runtime information -----------------------------------------------

* Loaded script: bug-1.rb

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 fiber.so
    3 rational.so
    4 complex.so
    5 ruby2_keywords.rb
    6 set.rb

Aborted

Environment

Ruby version: ruby 3.5.0dev (2025-06-11 commit 970813d982) +PRISM

Platform: x86_64-linux

Built from source using latest master

Parser backend: Prism (default)

Updated by byroot (Jean Boussier) 2 days ago

  • Assignee set to prism

Updated by ufuk (Ufuk Kayserilioglu) 2 days ago

  • Backport changed from 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN to 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: REQUIRED
Actions #3

Updated by Anonymous 2 days ago

  • Status changed from Open to Closed

Applied in changeset git|5ec9a392cdf7f971221dc073dd466bce877d8acb.


[Bug #21439] Fix PM_SPLAT_NODE compilation error in for loops (#13597)

[Bug #21439] Fix PM_SPLAT_NODE compilation error in for loops

This commit fixes a crash that occurred when using splat nodes (*) as
the index variable in for loops. The error "Unexpected node type for
index in for node: PM_SPLAT_NODE" was thrown because the compiler
didn't know how to handle splat nodes in this context.

The fix allows code like for *x in [[1,2], [3,4]] to compile and
execute correctly, where the splat collects each sub-array.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0