More differential fuzzing bugs

Aperta
#4,480 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c, ruby
Ambito
compilers

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
C
Stelle
1k
Fork
206
Merge medio
1g 1h
PR unite (30g)
71

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ruby/prism

Tutte le issue di ruby/prism

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.