Commit 0acbbf7
TASK-032: DR-008 thread-safety contract stress test
Adds test/integ/threadsafety_stress.cpp with two sub-tests:
1. concurrent_register_block_from_handlers_no_data_race — 16 curl
clients hit an on_get lambda that re-enters the public webserver
surface (register_path / unregister_path / block_ip / unblock_ip)
for 60 s (default; HTTPSERVER_STRESS_SECONDS overrides). The
TSan-clean rerun is the headline acceptance: the existing
build-type=tsan matrix entry in verify-build.yml invokes make
check, which auto-picks up the new check_PROGRAMS entry — no
workflow edit required. Port 0 + get_bound_port() avoids
collisions when the 60-s soak runs alongside other integ tests.
2. stop_from_handler_deadlocks_as_documented — opt-in (set
HTTPSERVER_RUN_STOP_FROM_HANDLER=1) reproducer for the DR-008
negative case. Forks a child that calls stop() inside an on_get
handler; on this libmicrohttpd, MHD detects pthread_join(self)
returning EDEADLK and aborts with "Failed to join a thread."
The fork contains the abort so the parent test binary stays
healthy. Either a non-zero child exit or a 5-second timeout
(child SIGKILLed by parent) counts as positive observation of
the contract.
Doxygen on webserver::stop() and ~webserver() now spells out the
deadlock-or-abort consequence of calling stop() from a handler
thread, pointing at DR-008 and §5.1.
Test wall-clock: 60 s default, ~5 s minimum locally. Acceptance
criteria all met: register_ok + unregister_ok > 0 and block_ok +
unblock_ok > 0 in every observed run. Full make check -j1 passes
42/42.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2f7b4ea commit 0acbbf7
4 files changed
Lines changed: 420 additions & 9 deletions
File tree
- specs/tasks/M5-routing-lifecycle
- src/httpserver
- test
- integ
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
113 | 121 | | |
114 | 122 | | |
115 | 123 | | |
| |||
125 | 133 | | |
126 | 134 | | |
127 | 135 | | |
128 | | - | |
129 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
130 | 152 | | |
131 | 153 | | |
132 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
236 | 250 | | |
237 | 251 | | |
238 | 252 | | |
| |||
0 commit comments