Skip to content

Conversation

jedisct1
Copy link
Contributor

@jedisct1 jedisct1 commented Oct 2, 2025

The readIndirect function was incorrectly returning 0 when processing application_data, even though it had successfully read and decrypted data into the buffer.

Fixes #25428

Reported by @Southporter -- Thanks!

The readIndirect function was incorrectly returning 0 when processing
application_data, even though it had successfully read and decrypted
data into the buffer.

Fixes ziglang#25428
@squeek502
Copy link
Member

squeek502 commented Oct 2, 2025

This fix doesn't seem correct; readIndirect always returning 0 should be correct in terms of the stream and readVec APIs.

  • stream returns how many bytes are written to w, and w is discarded so stream should always return 0
  • readVec returns how many bytes were written to data, and data is discarded so readVec should always return 0

My preliminary guess is that the infinite loop is caused by the buffer being full during a stream call so the buffer just stays full forever and some Reader function loops infinitely. If so, doing a rebase in stream to make room might be a possible fix (here's an example of that sort of thing in the flate decompressor). Will look into it, though; that's just a guess at this point.

EDIT: It actually seems to be getting stuck during a readv syscall for me on Linux. The syscall is called and never returns? Not sure what would cause that.

EDIT#2: The hanging readv is coming from input.peek here so in theory this should be unrelated to tls.Client and more related to File.Reader (which is what input is in the reproduction)

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.

std.crypto.tls.Client hangs on reading application data
2 participants