You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(*ClientConn).encodeTrailers encodes into a per-conn buffer (cc.hbuf). Trailers are encoded with cc.mu held, but written with only cc.wmu held. If another request on the same ClientConn uses the buffer while the trailers are being written, a race occurs.
Operations which examine the state of a ClientConn--notably,
the connection pool's check to see if a conn is available to
take a new request--need to acquire mu. Blocking while holding mu,
such as when writing to the network, blocks these operations.
Remove blocking operations from the mutex.
Perform network writes with only ClientConn.wmu held.
Clarify that wmu guards the per-conn HPACK encoder and buffer.
Add a new mutex guarding request creation, covering the critical
section starting with allocating a new stream ID and continuing
until the stream is created.
Fix a locking issue where trailers were written from the HPACK
buffer with only wmu held, but headers were encoded into the buffer
with only mu held. (Now both encoding and writes occur with wmu
held.)
Fixesgolang/go#32388.
Fixesgolang/go#48340.
Change-Id: Ibb313424ed2f32c1aeac4645b76aedf227b597a3
Reviewed-on: https://go-review.googlesource.com/c/net/+/349594
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
(*ClientConn).encodeTrailers
encodes into a per-conn buffer (cc.hbuf
). Trailers are encoded withcc.mu
held, but written with onlycc.wmu
held. If another request on the sameClientConn
uses the buffer while the trailers are being written, a race occurs.https://go.googlesource.com/net/+/refs/heads/master/http2/transport.go#1417
Reproduction below.
The text was updated successfully, but these errors were encountered: