Skip to content

Instantly share code, notes, and snippets.

@OneOfOne
Created February 5, 2022 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OneOfOne/19a21d652894034d97b0860e91365fc6 to your computer and use it in GitHub Desktop.
Save OneOfOne/19a21d652894034d97b0860e91365fc6 to your computer and use it in GitHub Desktop.
diff --git a/src/runtime/crash_test.go b/src/runtime/crash_test.go
index e0c0bac892..7bbe19aafb 100644
--- a/src/runtime/crash_test.go
+++ b/src/runtime/crash_test.go
@@ -8,7 +8,6 @@ import (
"bytes"
"flag"
"fmt"
- "internal/testenv"
"os"
"os/exec"
"path/filepath"
@@ -19,6 +18,8 @@ import (
"sync"
"testing"
"time"
+
+ "internal/testenv"
)
var toRemove []string
@@ -256,7 +257,6 @@ panic: again
if !strings.HasPrefix(output, want) {
t.Fatalf("output does not start with %q:\n%s", want, output)
}
-
}
func TestRecursivePanic2(t *testing.T) {
@@ -269,7 +269,6 @@ panic: third panic
if !strings.HasPrefix(output, want) {
t.Fatalf("output does not start with %q:\n%s", want, output)
}
-
}
func TestRecursivePanic3(t *testing.T) {
@@ -280,7 +279,6 @@ func TestRecursivePanic3(t *testing.T) {
if !strings.HasPrefix(output, want) {
t.Fatalf("output does not start with %q:\n%s", want, output)
}
-
}
func TestRecursivePanic4(t *testing.T) {
@@ -291,7 +289,6 @@ func TestRecursivePanic4(t *testing.T) {
if !strings.HasPrefix(output, want) {
t.Fatalf("output does not start with %q:\n%s", want, output)
}
-
}
func TestRecursivePanic5(t *testing.T) {
@@ -303,7 +300,6 @@ panic: third panic
if !strings.HasPrefix(output, want) {
t.Fatalf("output does not start with %q:\n%s", want, output)
}
-
}
func TestGoexitCrash(t *testing.T) {
@@ -392,12 +388,12 @@ func TestRuntimePanicWithRuntimeError(t *testing.T) {
close(ch)
},
2: func() {
- var ch = make(chan struct{})
+ ch := make(chan struct{})
close(ch)
ch <- struct{}{}
},
3: func() {
- var s = make([]int, 2)
+ s := make([]int, 2)
_ = s[2]
},
4: func() {
@@ -574,29 +570,31 @@ func TestConcurrentMapWrites(t *testing.T) {
}
testenv.MustHaveGoRun(t)
output := runTestProg(t, "testprog", "concurrentMapWrites")
- want := "fatal error: concurrent map writes"
+ want := "panic: concurrent map writes"
if !strings.HasPrefix(output, want) {
t.Fatalf("output does not start with %q:\n%s", want, output)
}
}
+
func TestConcurrentMapReadWrite(t *testing.T) {
if !*concurrentMapTest {
t.Skip("skipping without -run_concurrent_map_tests")
}
testenv.MustHaveGoRun(t)
output := runTestProg(t, "testprog", "concurrentMapReadWrite")
- want := "fatal error: concurrent map read and map write"
+ want := "panic: concurrent map read and map write"
if !strings.HasPrefix(output, want) {
t.Fatalf("output does not start with %q:\n%s", want, output)
}
}
+
func TestConcurrentMapIterateWrite(t *testing.T) {
if !*concurrentMapTest {
t.Skip("skipping without -run_concurrent_map_tests")
}
testenv.MustHaveGoRun(t)
output := runTestProg(t, "testprog", "concurrentMapIterateWrite")
- want := "fatal error: concurrent map iteration and map write"
+ want := "panic: concurrent map iteration and map write"
if !strings.HasPrefix(output, want) {
t.Fatalf("output does not start with %q:\n%s", want, output)
}
diff --git a/src/runtime/map.go b/src/runtime/map.go
index 111db56b01..118dc46cae 100644
--- a/src/runtime/map.go
+++ b/src/runtime/map.go
@@ -408,7 +408,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")
+ panic("concurrent map read and map write")
}
hash := t.hasher(key, uintptr(h.hash0))
m := bucketMask(h.B)
@@ -466,7 +466,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")
+ panic("concurrent map read and map write")
}
hash := t.hasher(key, uintptr(h.hash0))
m := bucketMask(h.B)
@@ -582,7 +582,7 @@ func mapassign(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer {
msanread(key, t.key.size)
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
hash := t.hasher(key, uintptr(h.hash0))
@@ -673,7 +673,7 @@ bucketloop:
done:
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
h.flags &^= hashWriting
if t.indirectelem() {
@@ -699,7 +699,7 @@ func mapdelete(t *maptype, h *hmap, key unsafe.Pointer) {
return
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
hash := t.hasher(key, uintptr(h.hash0))
@@ -790,7 +790,7 @@ search:
}
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
h.flags &^= hashWriting
}
@@ -855,7 +855,7 @@ func mapiternext(it *hiter) {
racereadpc(unsafe.Pointer(h), callerpc, funcPC(mapiternext))
}
if h.flags&hashWriting != 0 {
- throw("concurrent map iteration and map write")
+ panic("concurrent map iteration and map write")
}
t := it.t
bucket := it.bucket
@@ -987,7 +987,7 @@ func mapclear(t *maptype, h *hmap) {
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
h.flags ^= hashWriting
@@ -1018,7 +1018,7 @@ func mapclear(t *maptype, h *hmap) {
}
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
h.flags &^= hashWriting
}
diff --git a/src/runtime/map_fast32.go b/src/runtime/map_fast32.go
index 8d52dad217..a98790bdf4 100644
--- a/src/runtime/map_fast32.go
+++ b/src/runtime/map_fast32.go
@@ -18,7 +18,7 @@ func mapaccess1_fast32(t *maptype, h *hmap, key uint32) unsafe.Pointer {
return unsafe.Pointer(&zeroVal[0])
}
if h.flags&hashWriting != 0 {
- throw("concurrent map read and map write")
+ panic("concurrent map read and map write")
}
var b *bmap
if h.B == 0 {
@@ -58,7 +58,7 @@ func mapaccess2_fast32(t *maptype, h *hmap, key uint32) (unsafe.Pointer, bool) {
return unsafe.Pointer(&zeroVal[0]), false
}
if h.flags&hashWriting != 0 {
- throw("concurrent map read and map write")
+ panic("concurrent map read and map write")
}
var b *bmap
if h.B == 0 {
@@ -98,7 +98,7 @@ func mapassign_fast32(t *maptype, h *hmap, key uint32) unsafe.Pointer {
racewritepc(unsafe.Pointer(h), callerpc, funcPC(mapassign_fast32))
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
hash := t.hasher(noescape(unsafe.Pointer(&key)), uintptr(h.hash0))
@@ -173,7 +173,7 @@ bucketloop:
done:
elem := add(unsafe.Pointer(insertb), dataOffset+bucketCnt*4+inserti*uintptr(t.elemsize))
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
h.flags &^= hashWriting
return elem
@@ -188,7 +188,7 @@ func mapassign_fast32ptr(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer
racewritepc(unsafe.Pointer(h), callerpc, funcPC(mapassign_fast32))
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
hash := t.hasher(noescape(unsafe.Pointer(&key)), uintptr(h.hash0))
@@ -263,7 +263,7 @@ bucketloop:
done:
elem := add(unsafe.Pointer(insertb), dataOffset+bucketCnt*4+inserti*uintptr(t.elemsize))
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
h.flags &^= hashWriting
return elem
@@ -278,7 +278,7 @@ func mapdelete_fast32(t *maptype, h *hmap, key uint32) {
return
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
hash := t.hasher(noescape(unsafe.Pointer(&key)), uintptr(h.hash0))
@@ -354,7 +354,7 @@ search:
}
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
h.flags &^= hashWriting
}
diff --git a/src/runtime/map_fast64.go b/src/runtime/map_fast64.go
index f1368dc774..7e1e4703ce 100644
--- a/src/runtime/map_fast64.go
+++ b/src/runtime/map_fast64.go
@@ -18,7 +18,7 @@ func mapaccess1_fast64(t *maptype, h *hmap, key uint64) unsafe.Pointer {
return unsafe.Pointer(&zeroVal[0])
}
if h.flags&hashWriting != 0 {
- throw("concurrent map read and map write")
+ panic("concurrent map read and map write")
}
var b *bmap
if h.B == 0 {
@@ -58,7 +58,7 @@ func mapaccess2_fast64(t *maptype, h *hmap, key uint64) (unsafe.Pointer, bool) {
return unsafe.Pointer(&zeroVal[0]), false
}
if h.flags&hashWriting != 0 {
- throw("concurrent map read and map write")
+ panic("concurrent map read and map write")
}
var b *bmap
if h.B == 0 {
@@ -98,7 +98,7 @@ func mapassign_fast64(t *maptype, h *hmap, key uint64) unsafe.Pointer {
racewritepc(unsafe.Pointer(h), callerpc, funcPC(mapassign_fast64))
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
hash := t.hasher(noescape(unsafe.Pointer(&key)), uintptr(h.hash0))
@@ -173,7 +173,7 @@ bucketloop:
done:
elem := add(unsafe.Pointer(insertb), dataOffset+bucketCnt*8+inserti*uintptr(t.elemsize))
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
h.flags &^= hashWriting
return elem
@@ -188,7 +188,7 @@ func mapassign_fast64ptr(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer
racewritepc(unsafe.Pointer(h), callerpc, funcPC(mapassign_fast64))
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
hash := t.hasher(noescape(unsafe.Pointer(&key)), uintptr(h.hash0))
@@ -263,7 +263,7 @@ bucketloop:
done:
elem := add(unsafe.Pointer(insertb), dataOffset+bucketCnt*8+inserti*uintptr(t.elemsize))
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
h.flags &^= hashWriting
return elem
@@ -278,7 +278,7 @@ func mapdelete_fast64(t *maptype, h *hmap, key uint64) {
return
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
hash := t.hasher(noescape(unsafe.Pointer(&key)), uintptr(h.hash0))
@@ -356,7 +356,7 @@ search:
}
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
h.flags &^= hashWriting
}
diff --git a/src/runtime/map_faststr.go b/src/runtime/map_faststr.go
index 0673dd39c8..615415ffa9 100644
--- a/src/runtime/map_faststr.go
+++ b/src/runtime/map_faststr.go
@@ -18,7 +18,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")
+ panic("concurrent map read and map write")
}
key := stringStructOf(&ky)
if h.B == 0 {
@@ -113,7 +113,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")
+ panic("concurrent map read and map write")
}
key := stringStructOf(&ky)
if h.B == 0 {
@@ -208,7 +208,7 @@ func mapassign_faststr(t *maptype, h *hmap, s string) unsafe.Pointer {
racewritepc(unsafe.Pointer(h), callerpc, funcPC(mapassign_faststr))
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
key := stringStructOf(&s)
hash := t.hasher(noescape(unsafe.Pointer(&s)), uintptr(h.hash0))
@@ -291,7 +291,7 @@ bucketloop:
done:
elem := add(unsafe.Pointer(insertb), dataOffset+bucketCnt*2*sys.PtrSize+inserti*uintptr(t.elemsize))
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
h.flags &^= hashWriting
return elem
@@ -306,7 +306,7 @@ func mapdelete_faststr(t *maptype, h *hmap, ky string) {
return
}
if h.flags&hashWriting != 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
key := stringStructOf(&ky)
@@ -382,7 +382,7 @@ search:
}
if h.flags&hashWriting == 0 {
- throw("concurrent map writes")
+ panic("concurrent map writes")
}
h.flags &^= hashWriting
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment