More differential fuzzing bugs: 2

未關閉
#4,481 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
c, ruby
領域
compilers

研究方向

The report gives Ruby reproduction commands comparing parse.y and Prism for each discrepancy, but names no source files or tests. Start by running the listed commands with both parsers and identify which cases fail in Prism; then trace each failure to its parser code and regression tests. Done means Prism matches parse.y across all reported crash, semantic, syntax, and encoding cases.

由索引模型根據 Issue 內容生成。

描述

New findings from differential (parse.y vs Prism) and invariant fuzzing against upstream Prism a5e01d818fa45f2cea9232754251a6855f82ab98 / CRuby ruby 4.1.0dev (2026-11-25T22:05:35Z HEAD f46d41a54c) +PRISM.


Crash

  • PRISM_ASSERT abort in parse_write on self=&->.self=self=

    Reproduction
    ruby --parser=parse.y -ce 'self=&->.self=self='
    ruby --parser=prism   -ce 'self=&->.self=self='
    
    • parse.y: reports SyntaxError (Can't change the value of self / syntax error, unexpected &)
    • prism: aborts with assertion failure in parse_write:
      src/prism.c:13837: parse_write: Assertion `pm_parser_local_depth_constant_id(parser, name) == (int) depth' failed.
      [BUG] Aborted
      

Runtime / Semantic Discrepancies

  • Wrong operator precedence on 4-C::F!do end&.()

    Reproduction
    ruby --parser=parse.y -e 'module C; def self.F!; ->{ 1 }; end; end; p(4-C::F!do end&.())'
    ruby --parser=prism   -e 'module C; def self.F!; ->{ 1 }; end; end; p(4-C::F!do end&.())'
    
    • parse.y: 3 — parses as 4 - (C::F! do end&.())
    • prism: TypeError: Proc can't be coerced into Integer — parses as (4 - C::F! do end)&.()
  • Heredoc followed by line continuation (\\\n) misparses RHS of []|=

    Reproduction
    printf 'a = {}; def b(x = nil); [:b, x]; end\na[<<HEREDOC]|=b\\\nHEREDOC\n%%()\np a\n' | ruby --parser=parse.y
    printf 'a = {}; def b(x = nil); [:b, x]; end\na[<<HEREDOC]|=b\\\nHEREDOC\n%%()\np a\n' | ruby --parser=prism
    
    • parse.y: {"" => true} — parses RHS as b("") (%() is an argument to b)
    • prism: NoMethodError: undefined method '%' for an instance of Array — parses RHS as b % ()
  • Named regexp capture in CESU-8 creates a local variable in Prism but not in parse.y

    Reproduction
    printf '#coding:CESU-8\n/(?<\\ueee5>)/=~"a"\np local_variables\n' | ruby --parser=parse.y
    printf '#coding:CESU-8\n/(?<\\ueee5>)/=~"a"\np local_variables\n' | ruby --parser=prism
    
    • parse.y: [] (0 locals)
    • prism: [:"\uEEE5"] (1 local)

Syntax Acceptance / Rejection Discrepancies

  • `alias<<`` at EOF accepted by Prism

    Reproduction
    printf 'alias<<`' | ruby --parser=parse.y -c
    printf 'alias<<`' | ruby --parser=prism   -c
    
    • parse.y: SyntaxError: unterminated here document identifier
    • prism: Syntax OK
  • Heredoc followed by line continuation (\\\n) in modifier rescue hides unterminated heredoc

    Reproduction
    printf 'if t\nend\n<<HEREDOC rescue a\\\nHEREDOC\n<<H' | ruby --parser=parse.y -c
    printf 'if t\nend\n<<HEREDOC rescue a\\\nHEREDOC\n<<H' | ruby --parser=prism   -c
    
    • parse.y: SyntaxError: can't find string "H" anywhere before EOF
    • prism: Syntax OK
  • Literal \u{\n} inside string in CP1257 encoding accepted by Prism

    Reproduction
    printf '#coding:CP1257\nf"\\u{\\n}" ' | ruby --parser=parse.y -c
    printf '#coding:CP1257\nf"\\u{\\n}" ' | ruby --parser=prism   -c
    
    • parse.y: SyntaxError: invalid Unicode escape
    • prism: Syntax OK
  • def f(*)rescue*,();end rejected by Prism

    Reproduction
    ruby --parser=parse.y -ce 'def f(*)rescue*,();end'
    ruby --parser=prism   -ce 'def f(*)rescue*,();end'
    
    • parse.y: Syntax OK
    • prism: SyntaxError: expected an expression after '*'
  • #coding:IBM850\na'\x8A':?\u3042 rejected by Prism as invalid_symbol

    Reproduction
    printf '#coding:IBM850\na\x27\x8a\x27:?\\u3042 ' | ruby --parser=parse.y -c
    printf '#coding:IBM850\na\x27\x8a\x27:?\\u3042 ' | ruby --parser=prism   -c
    
    • parse.y: Syntax OK
    • prism: SyntaxError: invalid symbol
  • #coding:iso8859-1\nx=?\xa0^() accepted by Prism

    Reproduction
    printf '#coding:iso8859-1\nx=?\xa0^()' | ruby --parser=parse.y -c
    printf '#coding:iso8859-1\nx=?\xa0^()' | ruby --parser=prism   -c
    
    • parse.y: SyntaxError: syntax error, unexpected '?'
    • prism: Syntax OK

Magic Comment / Encoding Discrepancy

  • Encoding mismatch on #\x03:"coding:Windows-31J\\ at EOF

    Reproduction
    printf '#\x03:"coding:Windows-31J\\' | ruby --parser=parse.y -e 'RubyVM.keep_script_lines = true; p RubyVM::InstructionSequence.compile(STDIN.read).script_lines.first.encoding'
    printf '#\x03:"coding:Windows-31J\\' | ruby --parser=prism   -e 'RubyVM.keep_script_lines = true; p RubyVM::InstructionSequence.compile(STDIN.read).script_lines.first.encoding'
    
    • parse.y: #<Encoding:Windows-31J>
    • prism: #<Encoding:UTF-8>
主要語言
C
星號
1k
分支
206
平均合併
1 天 1 小時
30 天內合併 PR
71

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

ruby/prism 的其他 Issue

查看 ruby/prism 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。