More differential fuzzing bugs

オープン
#4,480 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c, ruby
領域
compilers

調査の方向性

Start with the differential reproductions in the issue, comparing Prism with parse.y to identify one mismatch at a time. The issue names pm_lambda_node_create and pm_heredoc_strspn_inline_whitespace for specific findings; inspect those entry points and relevant parser tests. Done means each reported reproduction matches parse.y behavior or is covered by a documented compatibility decision.

索引モデルが issue の本文から書いたものです。

説明

Findings from differential (parse.y vs Prism) and invariant fuzzing against Prism a5e01d818fa45f2cea9232754251a6855f82ab98 / CRuby ruby 4.1.0dev (2026-11-25T14:01:41Z HEAD 9d4d6c3c14) +PRISM.


Runtime / Semantic & Data-Corruption Bugs

  • Squiggly heredoc (<<~) silently strips \r and \f (0x0c) as indentation

    Reproduction
    ruby --parser=parse.y -e "p(<<~EOF)\n\rz\nEOF\n"
    ruby --parser=prism   -e "p(<<~EOF)\n\rz\nEOF\n"
    
    ruby --parser=parse.y -e "p(<<~EOF)\n\fz\nEOF\n"
    ruby --parser=prism   -e "p(<<~EOF)\n\fz\nEOF\n"
    
    • parse.y: "\rz\n" and "\fz\n" (only ' ' and '\t' count as indentation)
    • prism: "z\n" and "z\n" (pm_heredoc_strspn_inline_whitespace uses pm_char_is_inline_whitespace, which includes \r, \f, \v)
  • Squiggly heredoc (<<~) preserves leading spaces on whitespace-only lines

    Reproduction
    ruby --parser=parse.y -e "p(<<~EOF)\n \nEOF\n"
    ruby --parser=prism   -e "p(<<~EOF)\n \nEOF\n"
    

    (Also affects backtick heredocs <<~`E`\n \nE and single-quoted <<~'EOF'\n \nEOF.)

    • parse.y: "\n" (heredoc_indent remains INT_MAX, stripping all leading spaces/tabs)
    • prism: " \n" (resets common_whitespace to 0 when no content lines exist)
  • Regexp \u{...} escape silently strips \r in \r\n

    Reproduction
    ruby --parser=parse.y -e "p(/\\u{E\r\n}/.source.bytes)"
    ruby --parser=prism   -e "p(/\\u{E\r\n}/.source.bytes)"
    
    • parse.y: [92, 117, 123, 69, 13, 10, 125] (7 bytes)
    • prism: [92, 117, 123, 69, 10, 125] (6 bytes — drops \r)
  • %s\r\\\r\r silently preserves literal backslash in symbol literal

    Reproduction
    printf 'def s(x); p [x, x.name.bytes]; end\ns %%s\r\\\r\r' | ruby --parser=parse.y
    printf 'def s(x); p [x, x.name.bytes]; end\ns %%s\r\\\r\r' | ruby --parser=prism
    
    • parse.y: [:"\r", [13]] (1 byte — \ escapes the \r delimiter)
    • prism: [:"\\\r", [92, 13]] (2 bytes — keeps literal \)

AST Span Underflow

  • Unsigned length underflow in pm_lambda_node_create inside deeply nested unterminated heredocs

    Reproduction

    With PRISM_DEPTH_MAXIMUM=128 (or scaled nesting depth to hit nesting_too_deep):

    ./bin/parse -e $'{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{b(<<r\n#{% #{% #{<<C\n#{((->(<<B'
    
    • pm_lambda_node_create computes PM_TOKENS_LENGTH(&operator, &closing) with closing.end (73) < operator.start (77), producing length=4294967292 (-4) on PM_LAMBDA_NODE and propagating underflow to enclosing PM_PARENTHESES_NODEs and PM_STATEMENTS_NODE.

Syntax Parity (parse.y Accepts, Prism Rejects)

  • Fluent dot rejected after \r\r\n (r\r\r\n.O)

    Reproduction
    printf 'r\r\r\n.O' | ruby --parser=parse.y -c
    printf 'r\r\r\n.O' | ruby --parser=prism   -c
    ./bin/parse -e $'r\r\r\n.O'
    
    • parse.y: Syntax OK (r.O)
    • prism: SyntaxError: unexpected '.', ignoring it
  • C::F!do end.() rejected

    Reproduction
    ruby --parser=parse.y -c -e 'C::F!do end.()'
    ruby --parser=prism   -c -e 'C::F!do end.()'
    ./bin/parse -e 'C::F!do end.()'
    
    • parse.y: Syntax OK
    • prism: SyntaxError: unexpected 'do', expecting end-of-input
  • undef:f while:c rejected

    Reproduction
    ruby --parser=parse.y -c -e 'undef:f while:c'
    ruby --parser=prism   -c -e 'undef:f while:c'
    ./bin/parse -e 'undef:f while:c'
    
    • parse.y: Syntax OK
    • prism: SyntaxError: unexpected 'while', expecting end-of-input
  • c class<<t;rescue o do end;end rejected

    Reproduction
    ruby --parser=parse.y -c -e 'c class<<t;rescue o do end;end'
    ruby --parser=prism   -c -e 'c class<<t;rescue o do end;end'
    ./bin/parse -e 'c class<<t;rescue o do end;end'
    
    • parse.y: Syntax OK
    • prism: SyntaxError: expected a closing delimiter for the 'rescue' clause
  • Nested def with forwarding ... as default parameter value (def o b=def f...\nend\nend) rejected

    Reproduction
    ruby --parser=parse.y -c -e $'def o b=def f...\nend\nend'
    ruby --parser=prism   -c -e $'def o b=def f...\nend\nend'
    ./bin/parse -e $'def o b=def f...\nend\nend'
    
    • parse.y: Syntax OK
    • prism: SyntaxError: unexpected ..., ignoring it / expected a delimiter to close the parameters
  • Heredoc followed by %w[ across newline (<<A+%w[\nA\n ]) rejected

    Reproduction
    printf '<<A+%%w[\nA\n ]\n' | ruby --parser=parse.y -c
    printf '<<A+%%w[\nA\n ]\n' | ruby --parser=prism   -c
    ./bin/parse -e $'<<A+%w[\nA\n ]\n'
    
    • parse.y: Syntax OK ("" + [])
    • prism: SyntaxError: expected a delimiter to close the '%w' list (list_w_lower_element)

Syntax Parity (parse.y Rejects, Prism Accepts)

  • Missing void value expression error on o(return r z do end.t)

    Reproduction
    ruby --parser=parse.y -c -e 'o(return r z do end.t)'
    ruby --parser=prism   -c -e 'o(return r z do end.t)'
    ./bin/parse -e 'o(return r z do end.t)'
    
    • parse.y: SyntaxError: void value expression
    • prism: Syntax OK
  • Dangling quoted label "": accepted in pattern matching (o=>1,"":)

    Reproduction
    ruby --parser=parse.y -c -e 'o=>1,"":'
    ruby --parser=prism   -c -e 'o=>1,"":'
    ./bin/parse -e 'o=>1,"":'
    
    • parse.y: SyntaxError: syntax error, unexpected tLABEL_END
    • prism: Syntax OK
  • Invalid multibyte byte accepted after \ in non-UTF-8 encodings (CESU-8 %w[\\\x8d], Windows-31J '\\\xff')

    Reproduction
    printf '#coding:CESU-8\nf=%%w[\\\x8d]\n' | ruby --parser=parse.y -c
    printf '#coding:CESU-8\nf=%%w[\\\x8d]\n' | ruby --parser=prism   -c
    
    printf '#coding:sjis\n\x27\\\xff\x27\n' | ruby --parser=parse.y -c
    printf '#coding:sjis\n\x27\\\xff\x27\n' | ruby --parser=prism   -c
    
    • parse.y: SyntaxError: invalid multibyte char (CESU-8) / invalid multibyte char (Windows-31J)
    • prism: Syntax OK
  • Interpolated regexp parse-time validation & /n encoding option mismatch

    Reproduction

    Prism rejects statically-interpolated regexps at parse time (breaking dead-code / defined? parity), while accepting /#{"\xcd"} /n:

    ruby --parser=parse.y -e 'if false; /#{"["}/; end; puts :ok'
    ruby --parser=prism   -e 'if false; /#{"["}/; end; puts :ok'
    
    ruby --parser=parse.y -c -e 'defined? /\M- #@f/'
    ruby --parser=prism   -c -e 'defined? /\M- #@f/'
    
    printf '/#{"\\xcd"} /n\n' | ruby --parser=parse.y -c
    printf '/#{"\\xcd"} /n\n' | ruby --parser=prism   -c
    
    • /#{"["}/ & defined? /\M- #@f/: parse.y accepts (ok / Syntax OK); prism raises SyntaxError (regexp_parse_error / invalid_multibyte_escape)
    • /#{"\xcd"} /n: parse.y raises SyntaxError: regexp encoding option 'n' differs from source encoding 'UTF-8'; prism accepts (Syntax OK)

Encoding & Magic-Comment Parity

  • Encoding / shebang mismatch on #!\n!#coding:ASCII-8BIT

    Reproduction
    printf '#!\n!#coding:ASCII-8BIT\np __ENCODING__\n' | ruby --parser=parse.y
    printf '#!\n!#coding:ASCII-8BIT\np __ENCODING__\n' | ruby --parser=prism
    
    • parse.y: LoadError: no Ruby script found in input (and RubyVM::AbstractSyntaxTree.parse resolves ASCII-8BIT)
    • prism: #<Encoding:UTF-8>
  • Magic-comment discrepancy on #|:"coding:\

    Reproduction
    printf '#|:"coding:\\' | ruby --parser=parse.y -c
    printf '#|:"coding:\\' | ruby --parser=prism   -c
    ./bin/parse -e '#|:"coding:\'
    
    • parse.y: ArgumentError: unknown encoding name:
    • prism: Syntax OK
主要言語
C
スター
1k
フォーク
206
平均マージ
1日 1時間
マージ済み PR(30日)
71

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ruby/prism のほかの issue

ruby/prism の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。