More differential fuzzing bugs: 2

Đang mở
#4,481 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, ruby
Lĩnh vực
compilers

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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>
Ngôn ngữ chính
C
Star
1k
Fork
206
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
71

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ruby/prism

Tất cả issue của ruby/prism

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.