From 1956b28ae3cf5e75fd8ad193d3ceec183581844b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20Chigot?= Date: Mon, 25 Feb 2019 09:44:33 +0100 Subject: [PATCH] runtime: call atomic.Storeuintptr in noteclear on AIX The memory might not be synchronized in a thread being woken up after a semasleep. Using atomic instructions in noteclear function will force this synchronisation. Fixes #30189 Change-Id: If7432f29b2a1a56288231822db52f3f8d1d6dbfe Reviewed-on: https://go-review.googlesource.com/c/go/+/163624 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/runtime/lock_sema.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/runtime/lock_sema.go b/src/runtime/lock_sema.go index fcc531ce78..b36c97f71e 100644 --- a/src/runtime/lock_sema.go +++ b/src/runtime/lock_sema.go @@ -122,7 +122,13 @@ func unlock(l *mutex) { // One-time notifications. func noteclear(n *note) { - n.key = 0 + if GOOS == "aix" { + // On AIX, semaphores might not synchronize the memory in some + // rare cases. See issue #30189. + atomic.Storeuintptr(&n.key, 0) + } else { + n.key = 0 + } } func notewakeup(n *note) { -- 2.50.0