Skip to content

Avoid a reference Restls server deadlock in carrier tests - #12

Merged
MimoProxy merged 1 commit into
mainfrom
kernel/restls-deadline
Nov 22, 2026
Merged

MimoProxy merged 1 commit into
mainfrom
kernel/restls-deadline

Conversation

@MimoProxy

Copy link
Copy Markdown
Owner

TestTLSCarriersAgainstPinnedReference/*/grpc/03-restls occasionally hung until the compatibility job hit its 10-minute timeout.

Cause

The hang is in the pinned reference Restls server (restls-client-go v0.1.9, restls_server.go), not in our client.

The deadlock, from the reference peer's goroutines while hung:

  • Write holds writeMu, then waits in waitToClientWritable for a client record.
  • Read gets a client record asking for a reply (ActResponse > 0) and calls writeRestlsRecords(nil). That blocks on the same writeMu.
  • Read is stuck, so the record Write is waiting for is never processed.

From the socket queues while hung:

  • The peer's socket had ~400 KB unread in its receive queue.
  • The client had already sent everything.

Why the TLS 1.2 case over gRPC/HTTP hits it:

  • The default script (250?100<1,350~100<1,...) asks for replies in its first two records.
  • HTTP/2 transports write from both ends at once.

Change (test only)

  • Over gRPC and HTTP, use the default script without its reply commands. The plain transport keeps the default script and still covers replies.
  • A watchdog closes a stalled stream after 20 seconds. A future hang fails one subtest instead of the whole job (the gRPC stream ignores deadlines).

Testing

  • Before: 4 parallel workers of the restls gRPC/HTTP subtests all hung within 4 minutes.
  • After: 4 × 150 rounds passed.
  • The plain-transport restls subtests (default script, with replies): 4 × 150 rounds passed.
  • make test and arm64 make vet pass for darwin, linux and android. On windows, make vet fails only in ignored local bin/ packages, the same as on main.

🤖 Generated with Claude Code

The pinned reference Restls server holds its write lock while waiting
for a client record. If a client record that asks for a reply arrives
at that point, the read side blocks on the same lock and the server
stops reading. The default script asks for replies in its first two
records, and HTTP/2 transports write from both ends at once, so the
TLS 1.2 case over gRPC or HTTP occasionally hung until the job timed
out. The client was not at fault: it had sent everything and the
reference server had stopped reading.

Over HTTP/2 transports, use the default script without its reply
commands. The plain transport keeps the default script and still
covers replies. A watchdog now closes a stalled stream after 20
seconds so a hang fails the subtest instead of the whole job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MimoProxy
MimoProxy merged commit eb20d4e into main Nov 22, 2026
17 checks passed
@MimoProxy
MimoProxy deleted the kernel/restls-deadline branch November 22, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant