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
I'm adding support for WriteBatch to quic-go. Batching writes of QUIC (UDP) packets leads to a significant speedup of QUIC throughput, due to the reduced number of syscalls. Some connections set OOB, others don't, therefore the OOB field in the ipv{4,6}.Message will sometimes be set, other times it won't.
What did you expect to see?
I expect calls to WriteBatch to succeed.
What did you see instead?
Calls to WriteBatch occasionally return a sendmmsg: invalid argument error. I wrote a minimal example that reproduces the bug (even in the Go Playground): https://go.dev/play/p/lALtpTKEgw5
This leads to Control pointing to a memory location that might have already been reused between the two invocations. The kernel will thus see an invalid mmsghdr passed to the sendmmsg, and (rightfully) return an EINVAL error.
A sync.Pool is used to reduce allocations of the msghdr struct. When using a
struct obtained from the pool, the fields need to be cleared.
Fixesgolang/go#54693.
Change-Id: Ie693979abf3aa6bc3c834b9558c5029b376326e6
Reviewed-on: https://go-review.googlesource.com/c/net/+/425915
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
What version of Go are you using (
go version
)?with a current version of
x/net
:Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I'm adding support for
WriteBatch
to quic-go. Batching writes of QUIC (UDP) packets leads to a significant speedup of QUIC throughput, due to the reduced number of syscalls. Some connections set OOB, others don't, therefore theOOB
field in theipv{4,6}.Message
will sometimes be set, other times it won't.What did you expect to see?
I expect calls to
WriteBatch
to succeed.What did you see instead?
Calls to
WriteBatch
occasionally return asendmmsg: invalid argument
error. I wrote a minimal example that reproduces the bug (even in the Go Playground): https://go.dev/play/p/lALtpTKEgw5Why does this happen?
A
sync.Pool
is used to avoid allocations of themsghdr
struct: https://cs.opensource.google/go/x/net/+/b0a4917e:internal/socket/rawconn_mmsg.go;l=39-40.When the pool returns a
msghdr
where theControl
andControllen
is set (this happens if the previous user of the struct set OOB), it is not properly cleared if no OOB is set: https://cs.opensource.google/go/x/net/+/b0a4917e:internal/socket/msghdr_linux.go;l=14-16.This leads to
Control
pointing to a memory location that might have already been reused between the two invocations. The kernel will thus see an invalidmmsghdr
passed to thesendmmsg
, and (rightfully) return anEINVAL
error.Update: Here's a fix: https://go-review.googlesource.com/c/net/+/425914.
The text was updated successfully, but these errors were encountered: