Skip to content

Commit 9e8fa1e

Browse files
committed
runtime: eliminate poisonStack checks
We haven't used poisonStack since we switched to 1-bit stack maps (4d0f3a1), but the checks are still there. However, nothing prevents us from genuinely allocating an object at this address on 32-bit and causing the runtime to crash claiming that it's found a bad pointer. Since we're not using poisonStack anyway, just pull it out. Fixes #15831. Change-Id: Ia6ef604675b8433f75045e369f5acd4644a5bb38 Reviewed-on: https://go-review.googlesource.com/24211 Run-TryBot: Austin Clements <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent fca9fc5 commit 9e8fa1e

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/runtime/mbarrier.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func writebarrierptr(dst *uintptr, src uintptr) {
145145
if !writeBarrier.needed {
146146
return
147147
}
148-
if src != 0 && (src < sys.PhysPageSize || src == poisonStack) {
148+
if src != 0 && src < sys.PhysPageSize {
149149
systemstack(func() {
150150
print("runtime: writebarrierptr *", dst, " = ", hex(src), "\n")
151151
throw("bad pointer in write barrier")
@@ -164,7 +164,7 @@ func writebarrierptr_nostore(dst *uintptr, src uintptr) {
164164
if !writeBarrier.needed {
165165
return
166166
}
167-
if src != 0 && (src < sys.PhysPageSize || src == poisonStack) {
167+
if src != 0 && src < sys.PhysPageSize {
168168
systemstack(func() { throw("bad pointer in write barrier") })
169169
}
170170
writebarrierptr_nostore1(dst, src)

src/runtime/stack.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ const (
127127

128128
const (
129129
uintptrMask = 1<<(8*sys.PtrSize) - 1
130-
poisonStack = uintptrMask & 0x6868686868686868
131130

132131
// Goroutine preemption request.
133132
// Stored into g->stackguard0 to cause split stack check failure.
@@ -594,7 +593,7 @@ func adjustpointers(scanp unsafe.Pointer, cbv *bitvector, adjinfo *adjustinfo, f
594593
pp := (*uintptr)(add(scanp, i*sys.PtrSize))
595594
retry:
596595
p := *pp
597-
if f != nil && 0 < p && p < _PageSize && debug.invalidptr != 0 || p == poisonStack {
596+
if f != nil && 0 < p && p < _PageSize && debug.invalidptr != 0 {
598597
// Looks like a junk value in a pointer slot.
599598
// Live analysis wrong?
600599
getg().m.traceback = 2

0 commit comments

Comments
 (0)