]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: ensure sysStat for mheap_.arenas is aligned
authorAustin Clements <austin@google.com>
Tue, 20 Feb 2018 23:16:56 +0000 (18:16 -0500)
committerAustin Clements <austin@google.com>
Wed, 21 Feb 2018 03:27:07 +0000 (03:27 +0000)
We don't want to account the memory for mheap_.arenas because most of
it is never touched, so currently we pass the address of a uint64 on
the heap. However, at least on mips, it's possible for this uint64 to
be unaligned, which causes the atomic add in mSysStatInc to crash.

Fix this by instead passing a nil stat pointer.

Fixes #23946.

Change-Id: I091587df1b3066c330b6bb4d834e4596c407910f
Reviewed-on: https://go-review.googlesource.com/95695
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/runtime/malloc.go

index ecbae721dd78aef9c63ebecf5c7c544fd956a166..e9150fdbb613ebd9007b0d740b89235cd5d25471 100644 (file)
@@ -302,8 +302,7 @@ func mallocinit() {
 
        // Map the arena index. Most of this will never be written to,
        // so we don't account it.
-       var untracked uint64
-       mheap_.arenas = (*[memLimit / heapArenaBytes]*heapArena)(persistentalloc(unsafe.Sizeof(*mheap_.arenas), sys.PtrSize, &untracked))
+       mheap_.arenas = (*[memLimit / heapArenaBytes]*heapArena)(persistentalloc(unsafe.Sizeof(*mheap_.arenas), sys.PtrSize, nil))
        if mheap_.arenas == nil {
                throw("failed to allocate arena index")
        }