From 29bbca5c2c1ad41b2a9747890d183b6dd3a4ace4 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Fri, 4 Mar 2022 13:24:04 -0500 Subject: 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 Reviewed-by: Austin Clements Run-TryBot: Michael Pratt --- src/runtime/map_faststr.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/runtime/map_faststr.go') diff --git a/src/runtime/map_faststr.go b/src/runtime/map_faststr.go index 4dca882c63..006c24cee2 100644 --- a/src/runtime/map_faststr.go +++ b/src/runtime/map_faststr.go @@ -19,7 +19,7 @@ func mapaccess1_faststr(t *maptype, h *hmap, ky string) 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") } key := stringStructOf(&ky) if h.B == 0 { @@ -114,7 +114,7 @@ func mapaccess2_faststr(t *maptype, h *hmap, ky string) (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") } key := stringStructOf(&ky) if h.B == 0 { @@ -209,7 +209,7 @@ func mapassign_faststr(t *maptype, h *hmap, s string) unsafe.Pointer { racewritepc(unsafe.Pointer(h), callerpc, abi.FuncPCABIInternal(mapassign_faststr)) } if h.flags&hashWriting != 0 { - throw("concurrent map writes") + fatal("concurrent map writes") } key := stringStructOf(&s) hash := t.hasher(noescape(unsafe.Pointer(&s)), uintptr(h.hash0)) @@ -292,7 +292,7 @@ bucketloop: done: elem := add(unsafe.Pointer(insertb), dataOffset+bucketCnt*2*goarch.PtrSize+inserti*uintptr(t.elemsize)) if h.flags&hashWriting == 0 { - throw("concurrent map writes") + fatal("concurrent map writes") } h.flags &^= hashWriting return elem @@ -307,7 +307,7 @@ func mapdelete_faststr(t *maptype, h *hmap, ky string) { return } if h.flags&hashWriting != 0 { - throw("concurrent map writes") + fatal("concurrent map writes") } key := stringStructOf(&ky) @@ -383,7 +383,7 @@ search: } if h.flags&hashWriting == 0 { - throw("concurrent map writes") + fatal("concurrent map writes") } h.flags &^= hashWriting } -- cgit v1.3-5-g9baa