]> Cypherpunks repositories - gostls13.git/commit
runtime: fix race condition between timer and event handler
authorRichard Musiol <mail@richard-musiol.de>
Sat, 25 Apr 2020 16:53:53 +0000 (18:53 +0200)
committerRichard Musiol <neelance@gmail.com>
Sun, 31 May 2020 18:35:04 +0000 (18:35 +0000)
commit0452f9460f50f0f0aba18df43dc2b31906fb66cc
tree116a266bb5cca5b87c63b049eec61536f995c6c7
parent7dbbb5bacf4e52bc4efbd3caecdebf6ffb730783
runtime: fix race condition between timer and event handler

This change fixes a race condition between beforeIdle waking up the
innermost event handler and a timer causing a different goroutine to
wake up at the exact same moment. This messes up the wasm event handling
and leads to memory corruption. The solution is to make beforeIdle
return the goroutine that must run next and have findrunnable pick
this goroutine without considering timers again.

Fixes #38093
Fixes #38574

Change-Id: Iffbe99411d25c2730953d1c8b0741fd892f8e540
Reviewed-on: https://go-review.googlesource.com/c/go/+/230178
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/runtime/lock_futex.go
src/runtime/lock_js.go
src/runtime/lock_sema.go
src/runtime/proc.go
test/fixedbugs/issue38093.go [new file with mode: 0644]