Closed
Description
package main
var g *int
func h() {
g = nil
}
When compiled with -N
(optimizations off), the empty block on the write-barrier-disabled branch is marked as preemptible when it shouldn't be.
0x0018 00024 (/Users/khr/gowork/tmp7.go:6) MOVWU runtime.writeBarrier(SB), R0
0x0020 00032 (/Users/khr/gowork/tmp7.go:6) CBZW R0, 40
0x0024 00036 (/Users/khr/gowork/tmp7.go:6) JMP 44
0x0028 00040 (/Users/khr/gowork/tmp7.go:6) PCDATA $0, $-1
0x0028 00040 (/Users/khr/gowork/tmp7.go:6) JMP 64 <= this one
0x002c 00044 (/Users/khr/gowork/tmp7.go:6) PCDATA $0, $-2
0x002c 00044 (/Users/khr/gowork/tmp7.go:6) MOVD main.g(SB), R0
0x0034 00052 (/Users/khr/gowork/tmp7.go:6) CALL runtime.gcWriteBarrier1(SB)
0x0038 00056 (/Users/khr/gowork/tmp7.go:6) MOVD R0, (R25)
0x003c 00060 (/Users/khr/gowork/tmp7.go:6) JMP 64
0x0040 00064 (/Users/khr/gowork/tmp7.go:6) MOVD ZR, main.g(SB)
(PCDATA of -1 is preemptible, -2 is unpreemptible).
This could lead to very rare but nasty heap corruption when compiling with optimizations off (e.g. when running with Delve).