Skip to content

Give each SSL call its own byte count - #88

Merged
quinnj merged 2 commits into
JuliaWeb:mainfrom
krynju:kr/per-call-byte-counts
Oct 22, 2026
Merged

quinnj merged 2 commits into
JuliaWeb:mainfrom
krynju:kr/per-call-byte-counts

Conversation

@krynju

@krynju krynju commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Split out of #73, as asked in the review there: an independent fix, against main.

Bug. readbytes, writebytes, peekbuf and peekbytes are Refs on the stream, shared by every task using it, and read back after @geterror has released ssl.lock. Another task's SSL call can overwrite the count in that gap. A writer that reads back a smaller count than its own thinks its chunk was not written and submits most of it again, duplicating plaintext on the wire; reads and peeks have the same hole. On main the gap is the lock release just before the read-back, so it needs threads to hit; any change that moves the socket write out from under the lock (the #72 fix) widens it to every parked write.

Fix. Each call allocates its own Refs. The four fields stay on the struct, unused by this package, since code outside it reads transport.readbytes[].

Test. ConcurrentWriters: four writers with different chunk sizes on one stream, the server checks every writer's bytes arrived exactly once. It passes on main on one thread, where the window cannot be hit, and guards the invariant from here on.

The test file gains the same three helpers as #86 (self-signed server context, handshake loop, connected pair), in the same place, so whichever lands later only has to re-append its testset.

No version bump; the fixes can be released together.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.67%. Comparing base (10f7b7b) to head (cae23a7).
⚠️ Report is 50 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #88      +/-   ##
==========================================
+ Coverage   77.56%   81.67%   +4.11%     
==========================================
  Files           2        2              
  Lines        1083     1217     +134     
==========================================
+ Hits          840      994     +154     
+ Misses        243      223      -20     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

krynju and others added 2 commits October 22, 2026 15:35
`readbytes`, `writebytes`, `peekbuf` and `peekbytes` are `Ref`s on the
stream, shared by every task using it, and read back after `@geterror`
released `ssl.lock`. Another task's SSL call can overwrite the count in
that gap: a writer reading back a smaller count than its own thinks its
chunk was not written and submits most of it again, duplicating
plaintext on the wire. Reads and peeks have the same hole.

The counts are per call now. The fields stay on the struct, unused by
this package, because code outside it reads `transport.readbytes[]`.

Adds `ConcurrentWriters`: four writers with different chunk sizes, the
server checks every writer's bytes arrived exactly once.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@quinnj
quinnj force-pushed the kr/per-call-byte-counts branch from 9351f65 to cae23a7 Compare October 22, 2026 21:35
@quinnj
quinnj merged commit e1b3344 into JuliaWeb:main Oct 22, 2026
14 checks passed
@quinnj quinnj mentioned this pull request Oct 27, 2026
quinnj referenced this pull request Oct 27, 2026
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants