Skip to content

Commit 07e5527

Browse files
committed
reflect: fix methodValueCall code pointer mismatch in Value.Pointer
This is the port of CL 356809 for Value.Pointer to fix the mismatch of methodValueCall code pointer. Change-Id: I080ac41b94b44d878cd5896207a76a28c57fd48b Reviewed-on: https://go-review.googlesource.com/c/go/+/356950 Trust: Cuong Manh Le <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent d7149e5 commit 07e5527

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/reflect/all_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7724,9 +7724,12 @@ func TestNotInHeapDeref(t *testing.T) {
77247724
}
77257725

77267726
func TestMethodCallValueCodePtr(t *testing.T) {
7727-
p := ValueOf(Point{}).Method(1).UnsafePointer()
7727+
m := ValueOf(Point{}).Method(1)
77287728
want := MethodValueCallCodePtr()
7729-
if got := uintptr(p); got != want {
7729+
if got := uintptr(m.UnsafePointer()); got != want {
7730+
t.Errorf("methodValueCall code pointer mismatched, want: %v, got: %v", want, got)
7731+
}
7732+
if got := m.Pointer(); got != want {
77307733
t.Errorf("methodValueCall code pointer mismatched, want: %v, got: %v", want, got)
77317734
}
77327735
}

src/reflect/value.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,8 +1957,7 @@ func (v Value) Pointer() uintptr {
19571957
// created via reflect have the same underlying code pointer,
19581958
// so their Pointers are equal. The function used here must
19591959
// match the one used in makeMethodValue.
1960-
f := methodValueCall
1961-
return **(**uintptr)(unsafe.Pointer(&f))
1960+
return methodValueCallCodePtr()
19621961
}
19631962
p := v.pointer()
19641963
// Non-nil func value points at data block.

0 commit comments

Comments
 (0)