Undefined behaviour in re2c lexers caused by unspecified default rule.
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
Hi! [re2c author here] It came to my attention in this nixos thread that re2c emits a some serious warnings on the current code for the lexers, e.g. this one. When running re2c with -W (or version >= 4.0) you should see this:
sapi/phpdbg/phpdbg_lexer.l:80:20: warning: escape has no effect: '\.' [-Wuseless-escape]
sapi/phpdbg/phpdbg_lexer.l:64:0: warning: control flow in condition 'NORMAL' is undefined for strings that match
'\x22 [\x0\xA]'
'\x27 [\x0\xA]'
'\x22 \x22 [\x0\x9-\xA\xD\x20\x23]'
...
In particular, -Wundefined-control-flow warning indicates really serious issues; it is documented here. The fix should be simple: add default rule <*> * { /* error handling / abort / etc. */ }. Ideally also simplify some too-complex constructs like GENERIC_ID which make it hard to understand what's going on.
Some other warnings report unreachable rules, which is also not good (there's some rule that you think is doing something, but it's not).
I'm happy to help with further investigation and fixing these issues. I do recommend enabling the warnings from now on for all lexers - new bugs keep crawling in as the lexer code changes.
PHP Version
HEAD
Operating System
NixOS
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
sapi/phpdbg/phpdbg_lexer.l から始め、re2c を -W 付きで実行して undefined-control-flow、useless-escape、unreachable-rule 警告を再現します。lexer のルールと、影響を受ける他の lexer を調査し、その後、デフォルト処理が定義されていること、および関連する警告が解消されているか、意図的に対処されていることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100