Skip to content

Commit 3b43433

Browse files
etrclaude
andcommitted
Merge TASK-081: fill empty-on-correct-build unit suites; delete pthread detector
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2 parents cc60be4 + 56f23cf commit 3b43433

15 files changed

Lines changed: 653 additions & 88 deletions

Makefile.am

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -255,29 +255,20 @@ check-install-layout:
255255
# Cross-reference: keep HEADER_HYGIENE_FORBIDDEN in sync with the
256256
# #ifdef ladder in test/unit/header_hygiene_test.cpp.
257257
#
258-
# TASK-020 caveat (libc++ AND libstdc++ in thread mode): <pthread.h>
259-
# is intentionally absent from the forbidden list below. Both
260-
# mainstream STLs unconditionally pull <pthread.h> in from any STL
261-
# container header (<vector>, <string>, <map>, etc.) when threading
262-
# is enabled:
263-
# - libc++ (Apple's default STL on macOS) routes through
264-
# <__thread/support/pthread.h>.
265-
# - libstdc++ in thread-enabled mode (which is the default whenever
266-
# -D_REENTRANT is set, as configure.ac does) routes through
267-
# <bits/gthr-default.h>, which #include <pthread.h> directly.
268-
# The resulting `# N "...pthread.h"` line markers therefore appear in
269-
# the preprocessed output even though libhttpserver itself does not
270-
# include <pthread.h>. The runtime sentinel
271-
# test/unit/header_hygiene_test.cpp keeps the pthread guards but skips
272-
# them on both libc++ (_LIBCPP_VERSION) and libstdc++ in thread mode
273-
# (_GLIBCXX_HAS_GTHREADS), so the guards still fire on STLs that don't
274-
# route std::thread through pthread (e.g. MSVC's Microsoft STL).
275-
# pthread.h is intentionally absent from HEADER_HYGIENE_FORBIDDEN below
276-
# for the same reason: the grep-based check would produce false positives
277-
# on libc++ and libstdc++ in thread mode. The runtime sentinel in
278-
# test/unit/header_hygiene_test.cpp enforces the pthread invariant via
279-
# the #ifndef _LIBCPP_VERSION && !_GLIBCXX_HAS_GTHREADS guard ladder so
280-
# it still fires on STLs that do not route std::thread through pthread.
258+
# TASK-081 pthread-detector removal: <pthread.h> is intentionally absent
259+
# from the forbidden list below, AND the corresponding runtime-sentinel
260+
# guards in test/unit/header_hygiene_test.cpp have been removed
261+
# entirely. Both mainstream STLs (libc++ and libstdc++ in thread mode,
262+
# which is the default whenever -D_REENTRANT is set, as configure.ac
263+
# does) unconditionally pull <pthread.h> in from any STL container
264+
# header. The libhttpserver public surface uses STL containers
265+
# (std::string, std::vector, std::map in http_request.hpp, http_resource.hpp,
266+
# ip_representation.hpp, ...), so the pthread leak is structural to the
267+
# C++ standard library on every CI lane libhttpserver supports. The
268+
# detector could not be satisfied on any supported configuration without
269+
# rewriting the public surface to drop STL containers, which would
270+
# break source compatibility. See RELEASE_NOTES.md (Test infrastructure)
271+
# for the deletion rationale.
281272
# ---------------------------------------------------------------------------
282273

283274
# NOTE: each entry matches a basename; the grep in check-hygiene anchors with a

RELEASE_NOTES.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,23 @@ DR-011 ([specs/architecture/11-decisions/DR-011.md](specs/architecture/11-decisi
377377
CI signal. Two new CI lanes (`tls-no-cli`, plus a baseline canary)
378378
assert the SKIP wiring fires (or does not) as configured.
379379

380+
- **`<pthread.h>` runtime-sentinel guard removed (TASK-081).** The
381+
pthread leak detector in `test/unit/header_hygiene_test.cpp` (and
382+
its companion regex slot in `Makefile.am`'s `HEADER_HYGIENE_FORBIDDEN`)
383+
was unable to fire on any CI lane libhttpserver actually runs on. The
384+
libhttpserver public surface uses STL container headers
385+
(`std::string`, `std::vector`, `std::map`, ...) and both mainstream
386+
C++ standard libraries — libc++ via
387+
`<__thread/support/pthread.h>` and libstdc++ in thread-enabled mode
388+
via `<bits/gthr-default.h>` — unconditionally drag `<pthread.h>` in
389+
from those headers. Because the public surface cannot be rewritten
390+
to drop STL containers without a source-incompatible break, the
391+
pthread guard is structurally unsatisfiable on every supported
392+
configuration. The detector was deleted rather than kept as
393+
dead code gated on STL-implementation-detection macros. The
394+
remaining hygiene sentinels (`<microhttpd.h>`, `<gnutls/gnutls.h>`,
395+
`<sys/socket.h>`, `<sys/uio.h>`) continue to run on every CI lane.
396+
380397
## See also
381398

382399
- [README.md](README.md) — full v2.0 introduction and worked examples.

specs/tasks/M7-v2-cleanup/TASK-081.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ Several unit suites have near-zero effective coverage on the CI lanes that matte
1616
Make sure every suite actually exercises code on the build configuration where the feature is *available* (the inverse of what each gate currently does).
1717

1818
**Action Items:**
19-
- [ ] `webserver_ws_unavailable_test.cpp`: invert the guard so the suite exercises the `HAVE_WEBSOCKET`-off path (or rename + add a paired `webserver_ws_available_test.cpp` for the on-path). Goal: each build flag has a unit suite that runs.
20-
- [ ] `webserver_dauth_unavailable_test.cpp`: same pattern.
21-
- [ ] `header_hygiene_test.cpp`: investigate why the pthread leak detector was disabled on both stdlibs. Either fix the detector so it works (preferred — this is the entire purpose of the test) or delete the test with a documented `RELEASE_NOTES.md` entry. Coordinated with TASK-007.
22-
- [ ] `http_request_operator_stream_test.cpp`: split the credential-redaction tests into two — the `HAVE_BAUTH`-on variant pins redaction-when-set; the `HAVE_BAUTH`-off variant pins that the auth-related fields are absent from the stream.
23-
- [ ] `body_test.cpp` / `http_response_factories_test.cpp` / `iovec_entry_test.cpp`: write a Windows-shaped variant of the pipe/iovec tests using Windows native equivalents (CreateFileMapping for the fd source, etc.) or document the gap in `test/PORTABILITY.md`.
24-
- [ ] `webserver_register_ws_smartptr_test.cpp`: same pattern as `webserver_ws_unavailable_test`.
19+
- [x] `webserver_ws_unavailable_test.cpp`: invert the guard so the suite exercises the `HAVE_WEBSOCKET`-off path (or rename + add a paired `webserver_ws_available_test.cpp` for the on-path). Goal: each build flag has a unit suite that runs.
20+
- [x] `webserver_dauth_unavailable_test.cpp`: same pattern.
21+
- [x] `header_hygiene_test.cpp`: investigate why the pthread leak detector was disabled on both stdlibs. Either fix the detector so it works (preferred — this is the entire purpose of the test) or delete the test with a documented `RELEASE_NOTES.md` entry. Coordinated with TASK-007.
22+
- [x] `http_request_operator_stream_test.cpp`: split the credential-redaction tests into two — the `HAVE_BAUTH`-on variant pins redaction-when-set; the `HAVE_BAUTH`-off variant pins that the auth-related fields are absent from the stream.
23+
- [x] `body_test.cpp` / `http_response_factories_test.cpp` / `iovec_entry_test.cpp`: write a Windows-shaped variant of the pipe/iovec tests using Windows native equivalents (CreateFileMapping for the fd source, etc.) or document the gap in `test/PORTABILITY.md`.
24+
- [x] `webserver_register_ws_smartptr_test.cpp`: same pattern as `webserver_ws_unavailable_test`.
2525

2626
**Dependencies:**
2727
- Blocked by: None
@@ -37,4 +37,4 @@ Make sure every suite actually exercises code on the build configuration where t
3737
**Related Requirements:** PRD-FLG-REQ-003 (`features()` coverage)
3838
**Related Decisions:** None new
3939

40-
**Status:** Backlog
40+
**Status:** Done

specs/tasks/M7-v2-cleanup/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ TASK-093).
4545
| TASK-078 | Resolve commented-out CONNECT-method test bodies | HIGH | S | Done |
4646
| TASK-079 | Drive nonce/opaque state machine in v2 digest-auth integ tests | MED | M | Done |
4747
| TASK-080 | Tighten threadsafety_stress latency gate back from 100× to 10× | MED | M | Done |
48-
| TASK-081 | Fill empty-on-correct-build unit suites and re-enable pthread leak detector | MED | M | Backlog |
48+
| TASK-081 | Fill empty-on-correct-build unit suites and re-enable pthread leak detector | MED | M | Done |
4949
| TASK-082 | Tighten static-size bounds in `http_resource_test` and `webserver_pimpl_test` | MED | S | Backlog |
5050
| TASK-083 | Wire real CI gates into benchmarks | MED | M | Backlog |
5151
| TASK-084 | Re-measure libstdc++/Linux v1 baseline for `get_headers` ns/call | MED | S | Backlog |

0 commit comments

Comments
 (0)