Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
7ff8f3d
docs(agents): design the module test hardening for 34 popular libraries
ZheFeng7110 Nov 9, 2026
fa335c9
Modularize Boost.Conversion; export boost::core::string_view; fix the…
ZheFeng7110 Nov 9, 2026
3b81f2c
tests: move the smoke tests of 34 libraries under tests/<lib>/, add d…
ZheFeng7110 Nov 9, 2026
8554901
convert: export the converters and throw_on_failure; tests for uuid, …
ZheFeng7110 Nov 9, 2026
85ec27c
bimap: export the _key/_data lambda placeholders; port the 27 officia…
ZheFeng7110 Nov 9, 2026
ac82cae
tests: bloom, describe and container_hash suites; example ports with …
ZheFeng7110 Nov 9, 2026
61b5791
tests: hash2 suite (11 examples, every algorithm, hash_append over ea…
ZheFeng7110 Nov 9, 2026
3e60c0c
tests: unordered suite (example, documentation sections, concurrent v…
ZheFeng7110 Nov 9, 2026
5470b21
container: fix the pmr/devector.hpp include guard; container suite
ZheFeng7110 Nov 9, 2026
e42f563
regex: inline constexpr message tables (module consumers saw null str…
ZheFeng7110 Nov 9, 2026
ea2242b
url: export the charsets and grammar rules (BOOST_INLINE_CONSTEXPR); …
ZheFeng7110 Nov 10, 2026
5b083f1
json/container: export the kind tags and the placement new; json suite
ZheFeng7110 Nov 10, 2026
22e2708
tests: platform-independent expectations (MSVC ABI, demangled names, …
ZheFeng7110 Nov 10, 2026
abd1c80
decimal: std::format of decimal types through the module; decimal suite
ZheFeng7110 Nov 10, 2026
21aeb21
tests: harden asio (all official examples, overview and requirements …
ZheFeng7110 Nov 10, 2026
23362da
docs(agents): record the progress of the module test hardening
ZheFeng7110 Nov 10, 2026
117653a
tests: fix the CI legs (clang operator new, Windows, aarch64, asio ti…
ZheFeng7110 Nov 10, 2026
5da7691
tests/asio: POSIX-only local sockets, prioritised_handlers output, Wi…
ZheFeng7110 Nov 10, 2026
f98eabc
beast: export beast::errc; beast suite
ZheFeng7110 Nov 10, 2026
423fe58
tests/asio, beast: Windows doc root, macOS local probe, timer5, compo…
ZheFeng7110 Nov 10, 2026
b4338ca
cobalt: no main.hpp in the module, exported tags and protocols; cobal…
ZheFeng7110 Nov 10, 2026
9cc7483
tests: mqtt5 suite against an in-process broker
ZheFeng7110 Nov 10, 2026
fa52cf1
wrapper: geometry, math, interprocess, variant, config, dll export fi…
ZheFeng7110 Nov 11, 2026
4deef78
tests: geometry suite (examples, doc snippets, custom types)
ZheFeng7110 Nov 11, 2026
1fa747d
tests: math suite (examples, doc pages, custom types)
ZheFeng7110 Nov 11, 2026
3d659bf
tests: Boost.Test documentation and examples as whole programs
ZheFeng7110 Nov 11, 2026
72d07c9
tests/dll: plugin shared libraries and the dll tutorials
ZheFeng7110 Nov 11, 2026
50825e4
tests/asio family: hang watchdog, peer ignores backlog resets, cobalt…
ZheFeng7110 Nov 11, 2026
7b896d2
ci, docs: coverage check job, sub-project step, tests/ layout
ZheFeng7110 Nov 11, 2026
95c4ba6
tests: macOS, Windows and aarch64 fixes from CI
ZheFeng7110 Nov 11, 2026
59cc4b6
tests: cobalt spsc excluded, Windows-only crashes skipped, ooura check
ZheFeng7110 Nov 11, 2026
8ed11de
tests: cobalt/doc skipped on Windows, ooura cosine on 113-bit long do…
ZheFeng7110 Nov 11, 2026
ec1e192
tests, ci: asio timer measurement, tutorial9 typedef, tests/dll not o…
ZheFeng7110 Nov 11, 2026
1b6ac17
ci: tests/dll not on the static musl arm64 target
ZheFeng7110 Nov 11, 2026
1791359
docs: module test hardening record landed; open issues as a todo
ZheFeng7110 Nov 11, 2026
fa6c01b
exports, tests, ci: review fixes for PR #5
ZheFeng7110 Nov 11, 2026
f64c5e9
docs(agents): findings of the module tests and the upstream Boost bugs
ZheFeng7110 Nov 12, 2026
d0ad14b
tools: example porting scripts in tools/port_tests
ZheFeng7110 Nov 18, 2026
003aa49
tests: fix the windows-llvm-msvc process crashes (two clang module de…
ZheFeng7110 Nov 18, 2026
21c2a48
math: ooura_fourier_cos NaN on aarch64 Linux (musl ld128 libm + upstr…
ZheFeng7110 Nov 18, 2026
868aefe
serialization, thread: no declared exports on Windows; tests/dll runs…
ZheFeng7110 Nov 19, 2026
b691908
tests: sub-projects reuse the root build as workspace members; mcpp 2…
ZheFeng7110 Nov 20, 2026
9b8c2d1
docs(agents): sub-project build reuse record links mcpp#986 (instance…
ZheFeng7110 Nov 20, 2026
e7cc105
ci: pull_request path filter matches files under upstream/boost
ZheFeng7110 Nov 20, 2026
0187bf7
docs: default closure is 51 libraries (conversion; list adds bind, fu…
ZheFeng7110 Nov 21, 2026
913892f
tests: ex_peer_async bounds and paces retries after a reset before data
ZheFeng7110 Nov 21, 2026
44fae81
ci: coverage cases are checked against what the built test programs list
ZheFeng7110 Nov 21, 2026
ab050b6
tools: EXTRA_HEADERS comment names libs.json as the source of header …
ZheFeng7110 Nov 21, 2026
897eaf9
ci: test_template removes the fixture home when install_fixture fails
ZheFeng7110 Nov 21, 2026
ae11757
math: nonfinite_num_facets.hpp includes boost/config.hpp for BOOST_IN…
ZheFeng7110 Nov 21, 2026
25abafd
ci: test_coverage reads Boost.Test units that carry a description (na…
ZheFeng7110 Nov 21, 2026
db93463
docs(agents): record for the PR #5 review nits and the listing-based …
ZheFeng7110 Nov 21, 2026
282928c
cobalt: test and document co_main without main in the module; documen…
ZheFeng7110 Nov 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
703 changes: 703 additions & 0 deletions .agents/docs/2026-11-09-module-test-hardening-design.md

Large diffs are not rendered by default.

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions .agents/docs/2026-11-18-port-tests-tools-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
subject: tests
status: landed
---

# 示例移植脚本进入 `tools/port_tests/`:升级 Boost 时重跑上游测试的移植

> 日期:2026-11-18 · 分支 `test/module-test-hardening`
>
> 来源:[模块测试加固的遗留问题](todos/module-tests-open-issues.md) 的最后一项;
> [模块封装层测试加固](2026-11-09-module-test-hardening-design.md) §11.3 的“脚本”一段。

## 0. 结论

移植脚本整理后提交到 `tools/port_tests/`,入口是 `regen.py`。整理后的脚本重新生成 `tests/`,
与已提交的文件对照:只有两类差异,一是从不编译的输出(时间、线程完成顺序,见 §3),
二是两个比脚本旧的文件(bloom、container,按当前脚本重新生成)。
升级 Boost 的流程:

```sh
python3 tools/import_boost.py && python3 tools/apply_patches.py
python3 tools/port_tests/regen.py # 全部库;或 regen.py asio math:2
git diff tests/ # 审阅:新的输出、FLAG 行
python3 tools/ci/test_coverage.py scan --archive <tarball>
python3 tools/ci/test_coverage.py link -v
python3 tools/port_tests/mark_coverage.py <lib> excluded "<reason>" <path 片段>...
python3 tools/ci/test_coverage.py check
```

## 1. 布局

| 路径 | 内容 | 原来的位置 |
|---|---|---|
| `regen.py` | 入口:准备、按库/组并行运行、汇总 FLAG 行 | 各 `regen_*` 手工逐个运行 |
| `port_examples.py` | 移植器 | `.tmp/scripts/port_examples.py` |
| `net_gen.py` | 回环网络示例的驱动(asio、beast、cobalt、mqtt5 共用) | `net_gen.py` 与 `regen_asio_net.py` 中的副本 |
| `common.py` | 路径与准备步骤 | 散在各脚本里的 `.tmp/...` 路径 |
| `libs/<lib>.py` | 每个库的示例清单、选项与生成文件的头注释 | `regen_<lib>.py` / `.sh`、对话中一次性的命令(bloom) |
| `helpers/*.hpp` | harness(asio 回环、beast 客户端、cobalt、mqtt5 broker、临时目录) | `*_helpers.hpp` |
| `sources/<lib>.patch` | 移植前改过的示例源码(bimap 4 个、describe 1 个),对发布包的补丁 | `.tmp/ports/` 下的改过的副本 |
| `mark_coverage.py` | 批量设置 `coverage.toml` 条目的状态或用例 | `mark.py` |

工作目录是 `target/port-tests/`(已被忽略):发布包中 17 个库的 `libs/<lib>/`、打过补丁的源码、
oracle 库、日志。发布包就是 `tools/import_boost.py` 固定的那一个(核对 SHA-256),默认取
`target/vendor-import/` 下的,没有就下载。

## 2. 补上的、原来只在本地留下产物的步骤

- **oracle 库。** 原来是对话里手工编出的 `.tmp/oracle-libs/*.a`;现在由 `common.py` 的
`ORACLE_LIBRARIES` 描述(serialization、container 的 pmr、json、`port/system_extras.cpp`、
regex、program_options、url、thread、cobalt 的源码表取自 `mcpp.toml`),首次运行时编出。
- **asio 示例分类。** `asio_cls.txt` 是一次 grep 的结果(argv、acceptor、cin 的出现次数),
现在 `libs/asio.py` 每次从发布包重新统计,结果与原文件一致。
- **改过的示例源码** 改为补丁,`git apply` 到发布文件的副本上;生成文件引用的路径仍是发布包中的路径。
- 头注释原来由 shell 脚本用 `sed -n 1,Np` 从已提交的文件中取,现在写在 `libs/<lib>.py` 中。

未收入的:`count_snippets.py`、`doc_code.py`(调研用)、`mark_cases.py`、`mark_asio.py`
(`test_coverage.py link` 现在也按示例目录下的相对路径匹配 `example: <dir>/<stem>`,
覆盖了 `mark_cases.py`;`mark_asio.py` 的排除理由已在 `coverage.toml` 中,`scan` 会保留)、`mt.sh`。

## 3. 对照与修正

用 `.tmp/scripts/` 原样重跑一遍作为基线,再用整理后的脚本重跑,都与 `HEAD` 的 `tests/` 比较。

- **从不编译的输出会变。** `--output-unless 'X=1'` 的用例仍把 oracle 的输出写进 `#if !(1)` 块作参考,
其中的耗时、日期、线程顺序、随机读数每次都不同(asio 的 fork_join / parallel_sort / daytime
客户端、cobalt 的 thread、mqtt5 的 publisher)。重新生成时这些块的变化不必提交。
- **同一示例的多个 `--output-unless`。** 已提交的 asio `wait_for_all`、`ranged_wait_for_all`
有两层条件,而当时的脚本只保留最后一个。改为按参数顺序嵌套,外层在前。
- **math 的切分。** 已提交的四个文件(31/29/31/32 个用例)不是按步长切分的结果:后来排除的示例
是直接从文件里删掉的。改为“示例留在已有它的文件中,新示例放进用例最少的文件”,重现了已提交的
切分,升级时的 diff 也只涉及增删的示例。
- **bloom、container 比脚本旧。** 前者还是早期的 argv 写法,后者保留了 QuickBook 的
`/*<-*/` 标记(脚本后来会去掉)。按当前脚本重新生成;`mcpp test bloom/`、
`container/` 在 gcc 16.1.0 与 llvm 22.1.8 上通过。
- **bimap 的用例顺序。** 原脚本用 `ls` 列出 `example/*.cpp` 与 `mi_to_b_path/*.cpp`,顺序是
整条路径的字节序(`mi_to_b_path/` 在 `mighty_bimap.cpp` 之前);`libs/bimap.py` 照此排序。
- **callable_traits 头注释中的示例数** 改为统计发布包(现在仍是 37)。
- **`CLANG_NO_DEFAULT_CONFIG`。** `gen_exports.py` 需要它,oracle 不能有它(oracle 程序会链接失败,
用例随之不比对输出,不报错);`common.py` 在运行前把它从环境中去掉。
- oracle 程序的 60 秒超时在机器满载时偶有触发(Boost.Test 的 example 组与其他组并行时出现过一次,
单独重跑通过),表现为该任务失败:已写出的文件是完整的,其余保持原样,重跑该组即可。
134 changes: 134 additions & 0 deletions .agents/docs/2026-11-18-windows-msvc-module-crashes-analysis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
---
subject: tests
status: landed
---

# windows-llvm-msvc 上的进程崩溃:两个 clang 模块缺陷

> 日期:2026-11-18 · 分支 `fix/windows-msvc-crashes`(堆叠在 `test/module-test-hardening` 上)
>
> 来源:[模块测试加固的遗留问题](todos/module-tests-open-issues.md) 的第一项;
> [模块封装层测试加固](2026-11-09-module-test-hardening-design.md) §11.6 第 1 条。

## 0. 结论

三处崩溃都不是封装层的配置问题,而是 clang 在 MSVC ABI 下处理 C++20 模块时的两个缺陷,
llvm 22.1.8 与 23.1.3 上都会出现:

| 崩溃 | 原因 | 处理 |
|---|---|---|
| asio `composed_4`、`cobalt/doc`:堆损坏(0xC0000374) | 导入方展开模块中的 throw 时,生成的 CatchableType 缺拷贝构造函数(clice-io/xclang#27,修复为未合入的 llvm/llvm-project#114075),`exception_ptr` 按位复制异常对象,消息被释放两次 | 在该 TU 中让 Sema 检查一次同类型的 throw(不调用的函数) |
| math `daubechies_scaling`:SIGSEGV | std 模块与 math 模块 GMF 各有一份 MSVC 的 ppltasks,合并后 `_GetStaticAmbientSchedulerRef` 的 `call_once` lambda 写入的是该函数局部静态变量的另一份副本(与 llvm/llvm-project#221548 同形),`std::async` 读到空的调度器 | `tests/math/doc_sf.cpp` 先导入 math 再导入 std |

原先怀疑的方向(asio 的 `aligned_new` / `aligned_delete` 配对、`call_stack<>::top_` 在不同 GMF 中以
不同配置实例化)不成立。三项跳过都已删去。

## 1. 复现

Windows 主机上的实验通过 fork 上的堆叠 PR 进行:工作流 `windows-crash-repro.yml` 只构建相关测试程序,
先直接运行,再在 cdb 下运行(必要时开 full page heap)。三项都是**确定性**复现:composed_4 与
cobalt 文档程序每次以 0xC0000374 结束(cobalt 每次停在 `doc: race`),daubechies 每次 SIGSEGV。

Windows 腿的有效编译参数:`-fms-runtime-lib=dll -O0 -g`、MSVC 14.51.36231、
`-fms-compatibility-version=19.51.36260`,没有 `_DEBUG` / `_ITERATOR_DEBUG_LEVEL` 的差异。

## 2. 堆损坏:CatchableType 缺拷贝构造函数

cdb 在 0xC0000374 处的栈:`future<void>::get` → `rethrow_exception` → 展开时 `~future` →
`~exception_ptr` → `_ExceptionPtr_normal::_Destroy` → `~system_error` → `__std_exception_destroy` →
`free` 报堆损坏;page heap 下是 verifier stop 7(块已释放)。

同一个程序里,`boost::system::system_error` 的 CatchableType 有两份:

```
_CT??_R0?AVsystem_error@system@boost@@@848 # 无拷贝构造函数
_CT??_R0?AVsystem_error@system@boost@@@8??0system_error@system@boost@@QEAA@AEBV012@@Z48
```

cobalt 文档程序里另有 `std::bad_exception`、`with_throw_location<bad_exception>`、
`with_throw_location<system_error>` 的无拷贝构造函数版本。`_CT` / `_TI` 是 COMDAT-any,链接器可能
保留缺拷贝构造函数的一份;`make_exception_ptr` / `current_exception` 于是按位复制,两份对象共用
`what()` 的缓冲区。

原因(clice-io/xclang#27 的分析):`Sema::CheckCXXThrowOperand` 把选中的拷贝构造函数记在
`ASTContext` 的表中,这张表不写入 BMI;导入方展开来自模块的 throw(非模板 inline 函数,或模块
已实例化过的特化)时查不到,CatchableType 就不带拷贝构造函数。

用最小程序验证(每个用例单独一个进程):

| 程序 | 结果 |
|---|---|
| `import std` + asio 模块,只有 use_future 的错误路径 | 0xC0000374 |
| 同上,另有一个不调用的 `throw boost::system::system_error(...)` | 通过 |
| 只用文本包含,或只 `import std` 的 `make_exception_ptr` / `promise::set_exception` | 通过 |

TU 自己检查过该类型的 throw,表中就有条目,本 TU 生成的所有该类型(及其基类)的 CatchableType 都带
拷贝构造函数。因此:

- `tools/port_tests/helpers/asio.hpp`(内联进 `tests/asio/` 的 7 个移植文件)与 `tests/cobalt/doc.cpp`
在 `_MSC_VER` 下各加一个不调用的函数,throw 受影响的类型;cobalt 用两个 `with_throw_location<>`,
其基类覆盖其余类型。
- composed_4 去掉 `--only-if`;它打印 EINVAL 的系统文本(Windows 上是 WSA 的
“An invalid argument was supplied”,10022),输出只在 Windows 上不比较(`--output-unless`)。

这是使用方同样会遇到的问题:任何复制 Boost 异常的 TU(`use_future`、cobalt 的 promise / race、
`std::current_exception`)都可能中招。[docs/usage.md](../../docs/usage.md) §5 写明了现象与上述绕过。

## 3. SIGSEGV:ppltasks 的局部静态变量被合并成两份

崩溃栈:`daubechies_scaling` → `std::async` → `Concurrency::task_options::task_options` → 复制
`get_ambient_scheduler()` 返回的 `shared_ptr` 时读 `[0+8]`,即返回的引用本身是空地址。MSVC 14.51
的 `pplwin.h`:

```cpp
inline ::std::shared_ptr<scheduler_interface> & _GetStaticAmbientSchedulerRef()
{
static ::std::once_flag _Flag;
static ::std::shared_ptr<scheduler_interface> * _S_scheduler_address;
::std::call_once(_Flag, [] {
_S_scheduler_address = _GetStaticAmbientSchedulerStorage();
});
return *_S_scheduler_address;
}
```

出错的程序里这个静态变量有两份:

```
?_S_scheduler_address@?1??_GetStaticAmbientSchedulerRef@details@Concurrency@@YAAEAV?$shared_ptr@Uscheduler_interface@Concurrency@@@std@@XZ@4PEAV45@EA
?_S_scheduler_address@?1??_GetStaticAmbientSchedulerRef@details@Concurrency@@YAAEAV?$shared_ptr@Uscheduler_interface@Concurrency@@@std@@XZ@4PEAV45@EA.1
```

`.1` 是 LLVM 给同一目标文件中第二个同名全局变量加的后缀:clang 为 lambda 引用的变量另生成了一个
声明,函数体读一份、lambda 写另一份。MSVC STL 的 std 模块在 purview 中包含 `<future>`,math 模块的
GMF 经 `daubechies_scaling.hpp` 文本包含同一头文件,导入方合并两份定义时出错。这与
llvm/llvm-project#221548(lambda 的 `operator()` 与外层函数体分别取自两份模块副本)同形,但后者只
讨论了模板。

是否出错取决于 TU 先读到哪一份:

| 程序 | 结果 |
|---|---|
| 只 `import std`,或只用文本包含 | 通过 |
| `import std; import …asio;` + `std::async` | SIGSEGV |
| `import …asio; import std;` + `std::async` | 通过 |
| `import std; import …math;` + 只有 daubechies 一个用例 | 通过 |
| `tests/math/doc_sf.cpp`(std 在前) | SIGSEGV |
| `tests/math/doc_sf.cpp`(math 在前) | 通过 |

`doc_sf.cpp` 改为先导入 math。这是经验性的绕过,在其他测试程序中不能保证;修复要靠 clang。

## 4. 否决的方向

- **升级工具链**:llvm 23.1.3(mcpp 可装的最新版)上三项全部照旧。带 #114075 补丁的 xclang 23.1.5.2
不在 xlings 中。
- **让封装层统一处理**:缺陷出在导入方 TU 的代码生成,模块无法替导入方补上 Sema 的表项;
留下哪一份 `_CT` 由链接器决定,封装层无法让完整的一份胜出。
- **page heap 下由 cdb 截停**:verifier stop 7 直接结束进程,不进调试器;改为不开 page heap,
在 0xC0000374 处截停后取得释放栈。

## 5. 遗留

- clang 合入 #114075 后,删去 `helpers/asio.hpp` 与 `cobalt/doc.cpp` 中的 throw;#221548 一类的合并
缺陷修好后,`doc_sf.cpp` 的导入顺序可以恢复。
- 实验工作流 `windows-crash-repro.yml` 与驱动脚本 `.github/repro/windows_crash.py` 在合入前删去,见分支历史。
Loading
Loading