diff options
author | Richard Musiol <mail@richard-musiol.de> | 2020-04-25 18:53:53 +0200 |
---|---|---|
committer | Richard Musiol <neelance@gmail.com> | 2020-05-31 18:35:04 +0000 |
commit | 0452f9460f50f0f0aba18df43dc2b31906fb66cc (patch) | |
tree | 116a266bb5cca5b87c63b049eec61536f995c6c7 /src/runtime/lock_futex.go | |
parent | 7dbbb5bacf4e52bc4efbd3caecdebf6ffb730783 (diff) | |
download | go-0452f9460f50f0f0aba18df43dc2b31906fb66cc.tar.gz go-0452f9460f50f0f0aba18df43dc2b31906fb66cc.zip |
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>
Diffstat (limited to 'src/runtime/lock_futex.go')
-rw-r--r-- | src/runtime/lock_futex.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/runtime/lock_futex.go b/src/runtime/lock_futex.go index 29b7be0d8f..91467fdfae 100644 --- a/src/runtime/lock_futex.go +++ b/src/runtime/lock_futex.go @@ -238,8 +238,8 @@ func notetsleepg(n *note, ns int64) bool { return ok } -func beforeIdle(int64) bool { - return false +func beforeIdle(int64) (*g, bool) { + return nil, false } func checkTimeouts() {} |