aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/map.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2022-03-04 13:24:04 -0500
committerMichael Pratt <mpratt@google.com>2022-04-28 16:50:31 +0000
commit29bbca5c2c1ad41b2a9747890d183b6dd3a4ace4 (patch)
tree74ea0c8d0bed2673984f9c0767c40ace72fc0bb2 /src/runtime/map.go
parent4bb45f7549548add8222aa4f3040d0e2120691a9 (diff)
downloadgo-29bbca5c2c1ad41b2a9747890d183b6dd3a4ace4.tar.xz
runtime: differentiate "user" and "system" throws
"User" throws are throws due to some invariant broken by the application. "System" throws are due to some invariant broken by the runtime, environment, etc (i.e., not the fault of the application). This CL sends "user" throws through the new fatal. Currently this function is identical to throw, but with a different name to clearly differentiate the throw type in the stack trace, and hopefully be a bit more clear to users what it means. This CL changes a few categories of throw to fatal: 1. Concurrent map read/write. 2. Deadlock detection. 3. Unlock of unlocked sync.Mutex. 4. Inconsistent results from syscall.AllThreadsSyscall. "Thread exhaustion" and "out of memory" (usually address space full) throws are additional throws that are arguably the fault of user code, but I've left off for now because there is no specific invariant that they have broken to get into these states. For #51485 Change-Id: I713276a6c290fd34a6563e6e9ef378669d74ae32 Reviewed-on: https://go-review.googlesource.com/c/go/+/390420 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/map.go')
-rw-r--r--src/runtime/map.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/runtime/map.go b/src/runtime/map.go
index 2e513e2d52..65be4727fd 100644
--- a/src/runtime/map.go
+++ b/src/runtime/map.go
@@ -412,7 +412,7 @@ func mapaccess1(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer {
return unsafe.Pointer(&zeroVal[0])
}
if h.flags&hashWriting != 0 {
- throw("concurrent map read and map write")
+ fatal("concurrent map read and map write")
}
hash := t.hasher(key, uintptr(h.hash0))
m := bucketMask(h.B)
@@ -473,7 +473,7 @@ func mapaccess2(t *maptype, h *hmap, key unsafe.Pointer) (unsafe.Pointer, bool)
return unsafe.Pointer(&zeroVal[0]), false
}
if h.flags&hashWriting != 0 {
- throw("concurrent map read and map write")
+ fatal("concurrent map read and map write")
}
hash := t.hasher(key, uintptr(h.hash0))
m := bucketMask(h.B)
@@ -592,7 +592,7 @@ func mapassign(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer {
asanread(key, t.key.size)
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ fatal("concurrent map writes")
}
hash := t.hasher(key, uintptr(h.hash0))
@@ -683,7 +683,7 @@ bucketloop:
done:
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ fatal("concurrent map writes")
}
h.flags &^= hashWriting
if t.indirectelem() {
@@ -712,7 +712,7 @@ func mapdelete(t *maptype, h *hmap, key unsafe.Pointer) {
return
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ fatal("concurrent map writes")
}
hash := t.hasher(key, uintptr(h.hash0))
@@ -803,7 +803,7 @@ search:
}
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ fatal("concurrent map writes")
}
h.flags &^= hashWriting
}
@@ -870,7 +870,7 @@ func mapiternext(it *hiter) {
racereadpc(unsafe.Pointer(h), callerpc, abi.FuncPCABIInternal(mapiternext))
}
if h.flags&hashWriting != 0 {
- throw("concurrent map iteration and map write")
+ fatal("concurrent map iteration and map write")
}
t := it.t
bucket := it.bucket
@@ -1002,7 +1002,7 @@ func mapclear(t *maptype, h *hmap) {
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ fatal("concurrent map writes")
}
h.flags ^= hashWriting
@@ -1033,7 +1033,7 @@ func mapclear(t *maptype, h *hmap) {
}
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ fatal("concurrent map writes")
}
h.flags &^= hashWriting
}