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

reflect: MakeFunc crash on arm64 #52799

Closed
randall77 opened this issue May 9, 2022 · 1 comment
Closed

reflect: MakeFunc crash on arm64 #52799

randall77 opened this issue May 9, 2022 · 1 comment

Comments

@randall77
Copy link
Contributor

package main

import (
	"fmt"
	"reflect"
)

func f(next func() bool) {
	for b := next(); b; b = next() {
		fmt.Printf("next() returned %v\n", b)
	}
}

func main() {
	next := reflect.MakeFunc(reflect.TypeOf((func() bool)(nil)), func(_ []reflect.Value) []reflect.Value {
		return []reflect.Value{reflect.ValueOf(false)}
	})
	reflect.ValueOf(f).Call([]reflect.Value{next})
}

When run, it gives:

unexpected fault address 0x2000060c7a0
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0x2000060c7a0 pc=0x91738]

goroutine 1 [running]:
runtime.throw({0xb67bd?, 0x57074?})
	/workdir/go/src/runtime/panic.go:1028 +0x40 fp=0x4000093500 sp=0x40000934d0 pc=0x40c90
runtime.sigpanic()
	/workdir/go/src/runtime/signal_unix.go:830 +0x1a0 fp=0x4000093530 sp=0x4000093500 pc=0x55b30
fmt.(*pp).printArg(0x400009e750, {0xa65c0?, 0x2000060c7a0}, 0x76)
	/workdir/go/src/fmt/print.go:661 +0x508 fp=0x40000935e0 sp=0x4000093540 pc=0x91738
fmt.(*pp).doPrintf(0x400009e750, {0xb8df1, 0x13}, {0x4000093788?, 0x1, 0x1})
	/workdir/go/src/fmt/print.go:1026 +0x210 fp=0x40000936e0 sp=0x40000935e0 pc=0x94180
fmt.Fprintf({0xd7888, 0x40000a6008}, {0xb8df1, 0x13}, {0x4000093788, 0x1, 0x1})
	/workdir/go/src/fmt/print.go:204 +0x54 fp=0x4000093740 sp=0x40000936e0 pc=0x8e9c4
fmt.Printf(...)
	/workdir/go/src/fmt/print.go:213
main.f(0x4000098240)
	/workdir/go/src/test1.go:10 +0x80 fp=0x40000937a0 sp=0x4000093740 pc=0x95020
runtime.call16(0x4000098270, 0xbf0d0, 0x0, 0x0, 0x0, 0x8, 0x4000093ce0)
	/workdir/go/src/runtime/asm_arm64.s:461 +0x78 fp=0x40000937c0 sp=0x40000937a0 pc=0x6a6a8
runtime.reflectcall(0xa6880?, 0x4000098240?, 0x1?, 0xb8a94?, 0x0?, 0x12?, 0xa6880?)
	<autogenerated>:1 +0x34 fp=0x4000093800 sp=0x40000937c0 pc=0x6e034
reflect.Value.call({0xa6b40?, 0xbf0d0?, 0x1?}, {0xb6663, 0x4}, {0x4000093f50, 0x1, 0x1?})
	/workdir/go/src/reflect/value.go:585 +0x61c fp=0x4000093e70 sp=0x4000093800 pc=0x81bec
reflect.Value.Call({0xa6b40?, 0xbf0d0?, 0xbf0d8?}, {0x4000093f50?, 0x0?, 0x0?})
	/workdir/go/src/reflect/value.go:368 +0x90 fp=0x4000093ef0 sp=0x4000093e70 pc=0x81520
main.main()
	/workdir/go/src/test1.go:18 +0x148 fp=0x4000093f70 sp=0x4000093ef0 pc=0x952f8
runtime.main()
	/workdir/go/src/runtime/proc.go:250 +0x254 fp=0x4000093fd0 sp=0x4000093f70 pc=0x43284
runtime.goexit()
	/workdir/go/src/runtime/asm_arm64.s:1155 +0x4 fp=0x4000093fd0 sp=0x4000093fd0 pc=0x6c6c4

Works fine on amd64.

@randall77
Copy link
Contributor Author

Dup of #52788

@golang golang locked and limited conversation to collaborators May 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants