More differential fuzzing bugs

Đang mở
#4,480 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
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả 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

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.

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

Mô tả

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
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.