Open childe opened 2 weeks ago
It seems that under macOS, when the source function is at the very end of the executable binary file, there is a low probability that the libc execution in go-runtime will fail and a bus error occurs inside the macOS API. I tried the following methods and there will be no bus error:
func TestCount(t *testing.T) {
mockey.PatchConvey(`go test -v -gcflags="all=-N -l" -count=1 .`, t, func() {
mockey.Mock(FuncX).Return(100).Build()
r := FuncX()
convey.So(r, convey.ShouldEqual, 100)
})
runtime.KeepAlive(hugesize)
}
// A function with 4096 bytes of function body, not called anywhere
func hugesize()
I think it may has a little chance to happen when the entrance of called API and the source function being on the same page. It is rare for such test code to be overly simple in general use. So you don't need to worry about this in most cases. I will continue work on this issue. But due to the lack of feasible debugging ways on macOS, this may will not be fixed very soon.
Describe the bug
Occasionally triggers a SIGBUS: bus error
To Reproduce
run
for i in {1..100} ; do go test -v -gcflags="all=-N -l" -count=1 *.go || break; done
Expected behavior
all test cases pass without any error
Screenshots
Mockey version:
v1.2.12
Environment: __ arm64 darwin21.0
Additional context
Add any other context about the problem here.