// Private interface for the runtime.
const asanenabled = true
+const asanenabledBit = 1
// asan{read,write} are nosplit because they may be called between
// fork and exec, when the stack must not grow. See issue #50391.
)
const asanenabled = false
+const asanenabledBit = 0
// Because asanenabled is false, none of these functions should be called.
// lockVerifyMSize confirms that we can recreate the low bits of the M pointer.
func lockVerifyMSize() {
- size := roundupsize(unsafe.Sizeof(m{}), false) + mallocHeaderSize
+ size := roundupsize(unsafe.Sizeof(mPadded{}), false) + mallocHeaderSize
if size&mutexMMask != 0 {
print("M structure uses sizeclass ", size, "/", hex(size), " bytes; ",
"incompatible with mutex flag mask ", hex(mutexMMask), "\n")
unlock(&sched.lock)
}
- mp := new(m)
+ mp := &new(mPadded).m
mp.mstartfn = fn
mcommoninit(mp, id)
// Up to 10 locks held by this m, maintained by the lock ranking code.
locksHeldLen int
locksHeld [10]heldLockInfo
+}
+
+const mRedZoneSize = (16 << 3) * asanenabledBit // redZoneSize(2048)
+
+type mPadded struct {
+ m
// Size the runtime.m structure so it fits in the 2048-byte size class, and
// not in the next-smallest (1792-byte) size class. That leaves the 11 low
// bits of muintptr values available for flags, as required for
// GOEXPERIMENT=spinbitmutex.
- _ [goexperiment.SpinbitMutexInt * 64 * goarch.PtrSize / 8]byte
- _ [goexperiment.SpinbitMutexInt * 700 * (2 - goarch.PtrSize/4)]byte
+ _ [goexperiment.SpinbitMutexInt * (2048 - mallocHeaderSize - mRedZoneSize - unsafe.Sizeof(m{}))]byte
}
type p struct {