proc: fix rangeFuncStackTrace with inlined functions (#3849)

If an inlined function is encountered we should keep searching for its
rangeParent even if we don't have a closurePtr because it could be that
the function has been inlined into its rangeParent.

This does not need a new test, the existing tests already fail on
go1.24.
This commit is contained in:
Alessandro Arzilli 2024-11-04 17:21:40 +01:00 committed by GitHub
parent 822014b8e8
commit e9616a7f98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -964,7 +964,7 @@ func rangeFuncStackTrace(tgt *Target, g *G) ([]Stackframe, error) {
if fr.SystemStack { if fr.SystemStack {
return false return false
} }
if closurePtr == 0 && optimized(fr.Call.Fn) { if closurePtr == 0 && optimized(fr.Call.Fn) || frames[len(frames)-1].Inlined {
return true return true
} }
if closurePtr < 0 { if closurePtr < 0 {
@ -1021,7 +1021,7 @@ func rangeFuncStackTrace(tgt *Target, g *G) ([]Stackframe, error) {
if rangeParent == nil { if rangeParent == nil {
stop = true stop = true
} }
if !optimized(fr.Call.Fn) && closurePtr == 0 { if !optimized(fr.Call.Fn) && !fr.Inlined && closurePtr == 0 {
stop = true stop = true
} }
if stop { if stop {
@ -1042,6 +1042,11 @@ func rangeFuncStackTrace(tgt *Target, g *G) ([]Stackframe, error) {
stage = doneStage stage = doneStage
return false return false
} }
} else if frames[len(frames)-1].Inlined && !fr.Inlined && closurePtr == 0 {
frames = nil
addRetFrame = false
stage = doneStage
return false
} }
case lastFrameStage: case lastFrameStage:
frames = append(frames, fr) frames = append(frames, fr)