Undefined behaviour in re2c lexers caused by unspecified default rule.
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C
- Sterne
- 40.4k
- Forks
- 8.1k
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 96
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit sapi/phpdbg/phpdbg_lexer.l und führe re2c mit -W aus, um die Warnungen undefined-control-flow, useless-escape und unreachable-rule zu reproduzieren. Untersuche die Lexer-Regeln und die anderen betroffenen Lexer und überprüfe anschließend, dass die Standardbehandlung definiert ist und die relevanten Warnungen behoben oder bewusst behandelt wurden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100