You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: truncated COM_STMT_CLOSE and COM_STMT_RESET packets enter panic recovery #25744
The COM_STMT_CLOSE and COM_STMT_RESET branches decode a statement ID with binary.LittleEndian.Uint32(data[0:4]) without first checking len(data) >= 4.
A packet with 0-3 bytes panics with slice bounds out of range. The top-level recovery prevents the process from crashing, but it returns a non-nil Go error and constructs a response for COM_QUERY, so the protocol-level response is associated with the wrong command.
White-box tests using a three-byte payload reproduce the panic/recovery path for both commands.
Expected Behavior
Truncated COM_STMT_CLOSE and COM_STMT_RESET packets should be validated before decoding and return a normal protocol error response for the original command without entering panic recovery.
Steps to Reproduce
For each of COM_STMT_CLOSE and COM_STMT_RESET:
Create a minimal frontend session and command executor.
Call ExecRequest with payload []byte{1, 2, 3}.
Observe the recovered slice bounds out of range error and the response command being COM_QUERY.
Activity
Ariznawlll commentedon Jul 15, 2026
main 分支复核
origin/main@e538e203ad47ebf0506a424fe93aed61290c4061daviszhen commentedon Sep 21, 2026
#25756 (https://github.com/matrixorigin/matrixone/issues/25756)、#25744
(https://github.com/matrixorigin/matrixone/issues/25744)、#25743
(#25743) 均已由提交 e2c5dc0 / PR #25750
(e2c5dc0) 修复:
daviszhen commentedon Sep 21, 2026
本地 Docker 实测复核(2026-09-21):使用从当时最新
matrixorigin/main@df41cc24fc88fefab35151b494faa928c55eacb8构建的mo-service,直连 CN 的 MySQL 协议端口发送原始报文;已核对容器运行进程与构建产物的 SHA-256 一致。分别对 COM_STMT_CLOSE、COM_STMT_RESET 发送 payload 长度 0、1、2、3 的报文,共 8 个用例。8/8 均收到 MySQL ERR 20101,错误文本分别为
invalid COM_STMT_CLOSE packet与invalid COM_STMT_RESET packet;未见slice bounds out of range/ panic 日志,测试后的新连接与 COM_PING 仍正常。结论:此 issue 描述的短包进入 panic recovery 的问题在上述 main 提交上已无法复现。对应的
len(data) < 4检查由 e2c5dc0 / PR #25750 引入。Ariznawlll commentedon Sep 22, 2026
测试版本
main3727c5c5436ca136d7b0312f75bc223a11692a85原问题验证
截断的 COM_STMT_CLOSE 与 COM_STMT_RESET 数据包均返回 ERR,不再进入 panic recovery。
Happy Path 覆盖
完成原始 MySQL handshake 与 statement 生命周期,并在每个异常响应后以 COM_PING 验证连接持续可用。
Unhappy Path 覆盖
覆盖两类命令 payload 长度 0、1、2、3 的截断形式,单轮共 24 个畸形包,全部返回 ERR。
白盒验证
测试直接构造 wire packet,不经过驱动对 statement id 长度的校验,可直接命中服务端 COM_STMT_CLOSE/RESET 解码边界。
回归测试
新增
script/14_issue_regression/issue_25743_25744_25756_protocol_bounds.go及同名.sh入口,已提交至 motr#199。测试证据
协议场景连续执行 3 轮;本次新增 7 个 case 共执行 21 次,结果为
21/21通过。14_issue_regression整套执行时该场景也通过。MOTR 当前未为该分支上报远端 checks。测试结论
测试通过。
fix(frontend): silence missing binary statement closes (#31413)