aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorGerrit Code Review <noreply-gerritcodereview@google.com>2021-07-22 20:59:40 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-07-22 20:59:40 +0000
commit244267e8c4aebfadce5a43a7395ae59eacd76a21 (patch)
treef61cb67bfb398a757c04e38b59d55c5bcab62d26 /src/runtime
parentd8ceb133cac65b47c3f5bb292fbb28690c8b89a5 (diff)
parenta27e325c59691fba23c094ab07fd5735737ac8ba (diff)
downloadgo-244267e8c4aebfadce5a43a7395ae59eacd76a21.tar.gz
go-244267e8c4aebfadce5a43a7395ae59eacd76a21.zip
Merge "[dev.typeparams] all: merge master (798ec73) into dev.typeparams" into dev.typeparams
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/debug/panic_test.go3
-rw-r--r--src/runtime/malloc.go20
-rw-r--r--src/runtime/runtime2.go2
-rw-r--r--src/runtime/time.go5
4 files changed, 13 insertions, 17 deletions
diff --git a/src/runtime/debug/panic_test.go b/src/runtime/debug/panic_test.go
index b93631e1d8..65f9555f37 100644
--- a/src/runtime/debug/panic_test.go
+++ b/src/runtime/debug/panic_test.go
@@ -24,6 +24,9 @@ func TestPanicOnFault(t *testing.T) {
if runtime.GOOS == "ios" {
t.Skip("iOS doesn't provide fault addresses")
}
+ if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm" {
+ t.Skip("netbsd-arm doesn't provide fault address (golang.org/issue/45026)")
+ }
m, err := syscall.Mmap(-1, 0, 0x1000, syscall.PROT_READ /* Note: no PROT_WRITE */, syscall.MAP_SHARED|syscall.MAP_ANON)
if err != nil {
t.Fatalf("can't map anonymous memory: %s", err)
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index 8483ec99d8..f8d5d48a28 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -1126,13 +1126,21 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
msanmalloc(x, size)
}
+ if rate := MemProfileRate; rate > 0 {
+ // Note cache c only valid while m acquired; see #47302
+ if rate != 1 && size < c.nextSample {
+ c.nextSample -= size
+ } else {
+ profilealloc(mp, x, size)
+ }
+ }
mp.mallocing = 0
releasem(mp)
// Pointerfree data can be zeroed late in a context where preemption can occur.
// x will keep the memory alive.
if !isZeroed && needzero {
- memclrNoHeapPointersChunked(size, x)
+ memclrNoHeapPointersChunked(size, x) // This is a possible preemption point: see #47302
}
if debug.malloc {
@@ -1146,16 +1154,6 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
}
}
- if rate := MemProfileRate; rate > 0 {
- if rate != 1 && size < c.nextSample {
- c.nextSample -= size
- } else {
- mp := acquirem()
- profilealloc(mp, x, size)
- releasem(mp)
- }
- }
-
if assistG != nil {
// Account for internal fragmentation in the assist
// debt now that we know it.
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index d557ee8a3e..83d7d50b19 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -681,7 +681,7 @@ type p struct {
// timerModifiedEarlier status. Because the timer may have been
// modified again, there need not be any timer with this value.
// This is updated using atomic functions.
- // This is 0 if the value is unknown.
+ // This is 0 if there are no timerModifiedEarlier timers.
timerModifiedEarliest uint64
// Per-P GC state
diff --git a/src/runtime/time.go b/src/runtime/time.go
index 90e9b1139f..2f791c4ad8 100644
--- a/src/runtime/time.go
+++ b/src/runtime/time.go
@@ -669,11 +669,6 @@ func adjusttimers(pp *p, now int64) {
if verifyTimers {
verifyTimerHeap(pp)
}
- // There are no timers to adjust, so it is safe to clear
- // timerModifiedEarliest. Do so in case it is stale.
- // Everything will work if we don't do this,
- // but clearing here may save future calls to adjusttimers.
- atomic.Store64(&pp.timerModifiedEarliest, 0)
return
}