net/http: racy use of timers in http2Transport #37449
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
With these strategically-placed sleeps:
I get reliable crashes out of
GOTRACEBACK=system go test -race
innet/http
.The crash is a detected race between s.timer.Reset during the request writing goroutine (specifically a delayed body write) and s.timer.Stop during response processing of a 100 Continue header. Full stacks below.
The code is correct except for provoking the race panic. The timer setup is:
The request writing does:
If we get a 100 Continue then we stop the timer and run the function:
where on100 is:
The Stop is cleanup, and fnonce is protecting the actual work.
If this on100 Stop happens first, then s.timer.Stop above returns false, and s.timer.Reset does not run.
If the scheduleBodyWrite Stop happens first, then it's true that there is a race where maybe the
on100 Stop happens before the scheduleBodyWrite Reset, so that the timer still does fire after s.delay.
But the code is aware of that potential problem and using fnonce to address it.
This code is basically unchanged since it was written in 2016.
What changed is that the timers got pickier in Go 1.11.
If we don't remove the panic in #37400 then we need to rewrite this code.
The text was updated successfully, but these errors were encountered: