Skip to content

Commit 6735061

Browse files
committed
docs: the report said three findings; the self-review made it four
The fourth is the one the report would most have been improved by hiding: a crash in code written this round, found by re-reading it AFTER it was merged and green. Recorded with what the existing test missed and why.
1 parent 66e39ec commit 6735061

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

.agents/docs/2026-08-17-windows-three-axes-final-report.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ hermetic 容器、四条 cross-build、xlings 集成)。
195195
196196
---
197197

198-
## 3. 路上撞到的三件事(都不在计划里)
198+
## 3. 路上撞到的四件事(都不在计划里)
199199

200200
### 3.1 clang 在**两个目标上同时**出问题
201201

@@ -221,14 +221,35 @@ macOS 那一半后来被**拆分测试**定位到了:崩在 `ThePeFixtureItselfI
221221
可变字符串的 lambda)之后消失。夹具现在带一个 `MCPP_TEST_TRACE=1` 才开的分步 trace:
222222
如果它再来,一轮 CI 就能定位,而不是这次的四轮。
223223

224-
### 3.2 一处文档自相矛盾
224+
### 3.2 自审出来的一个崩溃(在已合入、已全绿之后)
225+
226+
合入之后重读 `binfmt.cppm`,发现 `identify()` —— 注释写着"never throws" ——
227+
在一种输入上会**终止进程**:
228+
229+
```cpp
230+
if (b.substr(*lfanew, 4) == "PE\0\0") // *lfanew 直接读自文件
231+
```
232+
233+
`std::string_view::substr``pos > size()` 时抛 `std::out_of_range`。一个以
234+
"MZ" 开头、0x3C 处是垃圾的文件是**普通的畸形输入**(下载了一半、DOS stub、一个
235+
`.exe` 的文本文件),而 `mcpp pack`**每一个**要打包的产物都调用它。
236+
237+
不是推理出来的,是量出来的:`std::string_view{256 字节}.substr(0xFFFFFFFF, 4)`
238+
在 libc++ 下抛 `string_view::substr`
239+
240+
模块里其它每一处读取都走了带边界检查的访问器,只有这两处比较是例外 —— 一个自称
241+
"对垃圾输入是全函数"的模块,就是这样不再是的。已改为 `has_at()`,并补了回归测试。
242+
原来的截断测试为什么没抓到:它构造的 `e_lfanew` 只落在**正好等于**文件末尾的位置,
243+
那里 `substr` 是良定义的、返回空。
244+
245+
### 3.3 一处文档自相矛盾
225246

226247
`docs/03-toolchains.md` 的 MinGW 段说 `[build] linkage` 这个键不存在、会被静默忽略;
227248
两百行之后的 MSVC 段**恰好**把它当成选 `/MT` 的写法展示。是照着文档写了一遍、看着 mcpp
228249
打印 `unsupported key 'linkage' (ignored)` 才发现的 —— 而跟着这一页做的用户,得到的也是
229250
这个,只是没人告诉他为什么什么都没变。两个语种都已修正。
230251

231-
### 3.3 `--mode static` 会覆盖用户点名的 target
252+
### 3.4 `--mode static` 会覆盖用户点名的 target
232253

233254
强制 musl 的那次重新 prepare 忽略了 `opts.targetTriple`,于是
234255
`--mode static --target x86_64-windows-gnu` 悄悄变成一次 **Linux** 构建。在 PE 打包

0 commit comments

Comments
 (0)