mirror of
https://github.com/golang/go
synced 2024-11-16 23:24:41 -07:00
internal/bisect: adjust stack PCs relative to Callers[2]
This is necessary to make hashes be consistent across runs, otherwise ASLR messes up search. Change-Id: Icf668dfe4c2008709f7767397b6700d0d5439287 Reviewed-on: https://go-review.googlesource.com/c/go/+/493857 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: David Chase <drchase@google.com>
This commit is contained in:
parent
fffddce55c
commit
841e99e283
@ -412,11 +412,18 @@ func (m *Matcher) Stack(w Writer) bool {
|
|||||||
func (m *Matcher) stack(w Writer) bool {
|
func (m *Matcher) stack(w Writer) bool {
|
||||||
const maxStack = 16
|
const maxStack = 16
|
||||||
var stk [maxStack]uintptr
|
var stk [maxStack]uintptr
|
||||||
n := runtime.Callers(3, stk[:])
|
n := runtime.Callers(2, stk[:])
|
||||||
if n == 0 {
|
// caller #2 is not for printing; need it to normalize PCs if ASLR.
|
||||||
|
if n <= 1 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base := stk[0]
|
||||||
|
// normalize PCs
|
||||||
|
for i := range stk[:n] {
|
||||||
|
stk[i] -= base
|
||||||
|
}
|
||||||
|
|
||||||
h := Hash(stk[:n])
|
h := Hash(stk[:n])
|
||||||
if m.ShouldPrint(h) {
|
if m.ShouldPrint(h) {
|
||||||
var d *dedup
|
var d *dedup
|
||||||
@ -437,7 +444,11 @@ func (m *Matcher) stack(w Writer) bool {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if !d.seen(h) {
|
if !d.seen(h) {
|
||||||
printStack(w, h, stk[:n])
|
// Restore PCs in stack for printing
|
||||||
|
for i := range stk[:n] {
|
||||||
|
stk[i] += base
|
||||||
|
}
|
||||||
|
printStack(w, h, stk[1:n])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user