]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix hashing of trace stacks
authorAustin Clements <austin@google.com>
Thu, 13 Aug 2015 03:39:10 +0000 (23:39 -0400)
committerAustin Clements <austin@google.com>
Mon, 14 Sep 2015 18:14:14 +0000 (18:14 +0000)
The call to hash the trace stack reversed the "seed" and "size"
arguments to memhash and, hence, always called memhash with a 0 size,
which dutifully returned a hash value that depended only on the number
of PCs in the stack and not their values. As a result, all stacks were
put in to a very subset of the 8,192 buckets.

Fix this by passing these arguments in the correct order.

Change-Id: I67cd29312f5615c7ffa23e205008dd72c6b8af62
Reviewed-on: https://go-review.googlesource.com/13613
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
src/runtime/trace.go

index c81846221a2531e1d5b2990bf72414159fe3589e..29600b5c4dd795f90b6b12381fdacd48980cee19 100644 (file)
@@ -624,7 +624,7 @@ func (tab *traceStackTable) put(pcs []uintptr) uint32 {
        if len(pcs) == 0 {
                return 0
        }
-       hash := memhash(unsafe.Pointer(&pcs[0]), uintptr(len(pcs))*unsafe.Sizeof(pcs[0]), 0)
+       hash := memhash(unsafe.Pointer(&pcs[0]), 0, uintptr(len(pcs))*unsafe.Sizeof(pcs[0]))
        // First, search the hashtable w/o the mutex.
        if id := tab.find(pcs, hash); id != 0 {
                return id