Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aarzilli committed Jul 8, 2024
1 parent 3a95fa9 commit 64687bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion _fixtures/rangeoverfunc.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (ti *TrickyIterator) iterAll(s []int) Seq2[int, int] {
// it make the closure escape to the heap which breaks the .closureptr
// heuristic. Eventually we will need to figure out what to do when that
// happens.
// ti.yield = yield
// ti.yield = yield // Save yield for future abuse
for i, v := range s {
if !yield(i, v) {
return
Expand Down
15 changes: 7 additions & 8 deletions pkg/proc/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func (frame *Stackframe) FramePointerOffset() int64 {
// contains returns true if off is between CFA and SP
func (frame *Stackframe) contains(off int64) bool {
p := uint64(off + int64(frame.stackHi))
//TODO: check that this is the right order!!!
return frame.Regs.SP() < p && p <= uint64(frame.Regs.CFA)
}

Expand Down Expand Up @@ -937,14 +936,14 @@ func rangeFuncStackTrace(tgt *Target, g *G) ([]Stackframe, error) {
nonMonotonicSP := false
var closurePtr int64

ap := func(fr Stackframe) {
appendFrame := func(fr Stackframe) {
frames = append(frames, fr)
if fr.closurePtr != 0 {
closurePtr = fr.closurePtr
}
}

closureptrok := func(fr *Stackframe) bool {
closurePtrOk := func(fr *Stackframe) bool {
if fr.SystemStack {
return false
}
Expand Down Expand Up @@ -979,7 +978,7 @@ func rangeFuncStackTrace(tgt *Target, g *G) ([]Stackframe, error) {

switch stage {
case 0:
ap(fr)
appendFrame(fr)
rangeParent = fr.Call.Fn.extra(tgt.BinInfo()).rangeParent
stage++
if rangeParent == nil || closurePtr == 0 {
Expand All @@ -988,11 +987,11 @@ func rangeFuncStackTrace(tgt *Target, g *G) ([]Stackframe, error) {
return false
}
case 1:
if fr.Call.Fn.offset == rangeParent.offset && closureptrok(&fr) {
ap(fr)
if fr.Call.Fn.offset == rangeParent.offset && closurePtrOk(&fr) {
appendFrame(fr)
stage++
} else if fr.Call.Fn.extra(tgt.BinInfo()).rangeParent == rangeParent && closureptrok(&fr) {
ap(fr)
} else if fr.Call.Fn.extra(tgt.BinInfo()).rangeParent == rangeParent && closurePtrOk(&fr) {
appendFrame(fr)
if closurePtr == 0 {
frames = nil
stage = 3
Expand Down

0 comments on commit 64687bd

Please sign in to comment.