Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proc: fix escapeCheck infinite recursion if something can not be #3311

Merged
merged 1 commit into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions _fixtures/reflecttypefncall.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"fmt"
"reflect"
)

func reflectFunc(value reflect.Value) {
fmt.Printf("%s\n", value.Type().Name())
}

func main() {
i := 2
val := reflect.ValueOf(i)
reflectFunc(val)
}
3 changes: 3 additions & 0 deletions pkg/proc/fncall.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,9 @@ func alignAddr(addr, align int64) int64 {
}

func escapeCheck(v *Variable, name string, stack stack) error {
if v.Unreadable != nil {
return fmt.Errorf("escape check for %s failed, variable unreadable: %v", name, v.Unreadable)
}
switch v.Kind {
case reflect.Ptr:
var w *Variable
Expand Down
10 changes: 10 additions & 0 deletions pkg/proc/proc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6043,3 +6043,13 @@ func TestFollowExec(t *testing.T) {
}
})
}

func TestEscapeCheckUnreadable(t *testing.T) {
// A failure in escapeCheck to dereference a field should not cause
// infinite recursion. See issue #3310.
withTestProcessArgs("reflecttypefncall", t, ".", []string{}, protest.AllNonOptimized, func(p *proc.Target, grp *proc.TargetGroup, fixture protest.Fixture) {
setFileBreakpoint(p, t, fixture.Source, 9)
assertNoError(grp.Continue(), t, "Continue")
proc.EvalExpressionWithCalls(grp, p.SelectedGoroutine(), "value.Type()", normalLoadConfig, true)
})
}