HTTP/2 pooled singleflight: 8 loopback TLS accepts under concurrent first requests (final-lock TOCTOU)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 18/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- networking
Research direction
Start with Transport.h2_dial_and_do in vlib/net/http/transport_h2.v, where the pool check and the final dial decision happen under separate mutex acquisitions. Then run the failing test test_h2_pool_dial_dedup_race at vlib/net/http/transport_h2_test.v:527 repeatedly to confirm the interleaving. Done means that test passes reliably with exactly one accepted connection and eight HTTP 200 responses, without weakening the assertions.
Written by the indexing model from the issue text.
Description
Actual executed master failure (not workflow-container state)
- Master SHA d8083d40873efc7689abdb15f4ca21b4f5d59f4a, Clang Linux production shard 3 job 136897140339, finished 2026-11-21 23:26 UTC, after 210 executed passes / 19 skips.
- The single actual failing test is
vlib/net/http/transport_h2_test.v:527test_h2_pool_dial_dedup_race. Eight concurrentfetch(enable_http2:true)callers all returned HTTP 200 but the scripted h2 TLS server counted 8 accepted connections, versus the expected 1 shared, multiplexed connection. Original reproduction:./vprod -cc clang -silent vlib/net/http/transport_h2_test.v, ideally repeated/with-keepc. This was not an external upstream response (local loopback listener), a deliberate failing fixture, GitHub job timeout or missing package. - The test file has blob SHA
5515c23c6a680444b1e9ed722e3da8c62fdf110fon both the failing SHA and master9621aa02fd7d7788700846e93242d08bd70a8aea: master advancement alone has not fixed/tested this.
Specific source-level race to discriminate
In vlib/net/http/transport_h2.v Transport.h2_dial_and_do:
- It first locks
t.mu, checkst.dialing[key], then readst.h2_conns[key]andt.key_proto[key], unlocks to try the pooled connection. - Later it relocks and checks only
t.dialing[key]before inserting a newH2DialCalland initiating a new ALPN/TLS dial. There is no recheck ofh2_conns[key]at this final atomic decision point.
Therefore an interleaving exists where caller A passes the unlocked pool check, caller B finishes a dial (registers h2_conns[key] and deletes dialing[key]), and caller A's final lock sees no pending dial and starts a redundant connection. This is a concrete TOCTOU in the source; whether it accounts for all eight accepts in this observed execution is unproven until traced. The earlier #27643 review addressed a related recheck, but the last decision remains split across two mutex acquisitions. The scripted server intentionally advertises max concurrent streams 100, so its stream limit should not drive redial.
Focused fix/validation requirements
Instrument pool key, Transport identity, dial call/connection ids and transitions with thread identifiers for eight workers; check whether the default transport is shared, whether an h2 pooled conn is retired between requests, and whether the final-lock gap is exercised. Implement an atomic decision for a currently reusable pooled connection versus an in-flight call versus a new dial, without holding t.mu across TLS I/O or entering an unbounded retry; preserve GOAWAY/closed retry behavior and h1-only fallback. Run original test repeatedly on native Linux Clang (prod/default, VJOBS1/4) and other supported backends, plus existing test_h2_dial_and_do_reuses_pooled_conn_instead_of_redialing, GOAWAY, fallback and connection-close tests. Keep exact one-accept/eight-200 assertions; no skip, timeout inflation or weakening.
Status: unresolved / investigating / still applicable. No local V checkout/compiler/formatter or original corrected native run was available for a safe patch in this environment.
- Dominant language
- V
- Stars
- 38.1k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 682
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vlang/v
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
Similar issues
-
[BUG] Regression in 9.2.0: `socket.c: error: storage size of 'info' isn't known`Possibly taken @barracuda156 claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 60/100
valkey-io/valkey#5551 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
manuscript-lang/manuscript#6389 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
apache/cloudstack#14784 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 Under an hour Newbie friendliness 62/100
zephyrproject-rtos/zephyr#126735 · 1 comment ·
Maintainers usually reply within 2 days
-
upnp > 18 fixesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BZFlag-Dev/bzflag#407 ·