php / php/php-src

Undefined behaviour in re2c lexers caused by unspecified default rule.

未关闭
#17,523 8 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Extension: pdo (core) SAPI: phpdbg Status: Verified
主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 13 小时
30 天内合并 PR
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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 sapi/phpdbg/phpdbg_lexer.l 开始,并使用 -W 运行 re2c,以重现 undefined-control-flow、useless-escape 和 unreachable-rule 警告。检查 lexer 规则和其他受影响的 lexer,然后确认默认处理已定义,并且相关警告已解决或得到有意处理。

由索引模型根据 Issue 内容生成。

评估

技术栈
c
领域
compilers
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。