-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
win10, amd64, go1.20.2
- define println0
- patch(stand, println0)
- patch(println0, redirector)
- call stand, expect it to jump to redirector
However, if redirector is defined by reflect.MakeFunc, step 4 seems to cause endless execution.
func println0() {
println(0)
}
// -gcflags='all=-N -l'
func Test_bad(t *testing.T) {
stand := reflect.MakeFunc(reflect.ValueOf(println0).Type(), nil)
_, err := mpatch.PatchMethodByReflectValue(stand, println0)
if err != nil {
panic(err.Error())
}
stand.Call(nil) // 0
_, err = mpatch.PatchMethodByReflectValue(reflect.ValueOf(println0), reflect.MakeFunc(reflect.ValueOf(println0).Type(), func(args []reflect.Value) (results []reflect.Value) {
println("redirector")
return nil
}))
if err != nil {
panic(err.Error())
}
stand.Call(nil) // endless
}
Metadata
Metadata
Assignees
Labels
No labels