agiledragon / gomonkey

gomonkey is a library to make monkey patching in unit tests easy
MIT License
1.92k stars 178 forks source link

[any 2023 update?] MacOS Apple Silicon - M1/M2, permissions denied - darwin/arm64 #122

Open paulmil1 opened 1 year ago

paulmil1 commented 1 year ago

internal gomonkey's call err := syscall.Mprotect(page, prot) returns permission denied

any update to make it work with ARM64 latest GO 1.20, Macos 12.6/13.0 has anyone figured out how to make the GOARCH=amd64 debugger work?

im looking for an ultimate solution, without having 'one or the other' situation with test working but debugger not and viceversa

can anybody confirm if downloading GO 1.17 with https://github.com/eisenxp/macos-golink-wrapper works? i see the issues of that repo and people claim its not working anymore on newer macs

Vex7eX commented 1 year ago

Same problem

Gordon-x commented 1 year ago

https://blog.csdn.net/weixin_42873928/article/details/129957307

lowang-bh commented 1 year ago

https://blog.csdn.net/weixin_42873928/article/details/129957307

Not works for me.

lowang-bh commented 1 year ago

The latest release of v2.10.1

testing.tRunner.func1.2({0x1020a40a0, 0x10327ada8})
    /usr/local/go/src/testing/testing.go:1526 +0x1c8
testing.tRunner.func1()
    /usr/local/go/src/testing/testing.go:1529 +0x364
panic({0x1020a40a0, 0x10327ada8})
    /usr/local/go/src/runtime/panic.go:884 +0x1f4
github.com/agiledragon/gomonkey/v2.modifyBinary(0x101aedcd0, {0x1400051e900, 0x18, 0x102050240?})
    /Users/wlh/go/src/github.com/volcano-sh/volcano/vendor/github.com/agiledragon/gomonkey/v2/modify_binary_darwin.go:9 +0xa0
github.com/agiledragon/gomonkey/v2.replace(0x101aedcd0, 0x101fc8ae0?)
    /Users/wlh/go/src/github.com/volcano-sh/volcano/vendor/github.com/agiledragon/gomonkey/v2/patch.go:269 +0x88
github.com/agiledragon/gomonkey/v2.(*Patches).ApplyCore(0x140002df930, {0x101fc8ae0?, 0x14000518ca0?, 0x0?}, {0x101fc8ae0, 0x1022cb9f0, 0x13})
    /Users/wlh/go/src/github.com/volcano-sh/volcano/vendor/github.com/agiledragon/gomonkey/v2/patch.go:213 +0x4c
github.com/agiledragon/gomonkey/v2.(*Patches).ApplyMethod(0x0?, {0x10228a4e0, 0x1022bfce0}, {0x101b27ea0, 0x11}, {0x101fc8ae0?, 0x1022cb9f0?})
    /Users/wlh/go/src/github.com/volcano-sh/volcano/vendor/github.com/agiledragon/gomonkey/v2/patch.go:92 +0x1b0
github.com/agiledragon/gomonkey/v2.ApplyMethod(...)
    /Users/wlh/go/src/github.com/volcano-sh/volcano/vendor/github.com/agiledragon/gomonkey/v2/patch.go:29
ns-chsu commented 12 months ago

I am suggesting running your unit test in docker images so the problem would not occur again. It works fine for me with the imagegolang:1.20. I am using M1.

lowang-bh commented 12 months ago

I am suggesting running your unit test in docker images so the problem would not occur again. It works fine for me with the imagegolang:1.20. I am using M1.

Yes, it works in docker and I did it to skip this error. But that's just a workaroud.

BlackSinny commented 11 months ago

I am suggesting running your unit test in docker images so the problem would not occur again. It works fine for me with the imagegolang:1.20. I am using M1.

it work successly on my mac, but it is necessary everyone need update file?

zoulux commented 10 months ago

mark

ShuaiGao commented 10 months ago

https://blog.csdn.net/weixin_42873928/article/details/129957307

worked out

Zh1Cheung commented 9 months ago

still have this problem, go monkey couldn't solve it thoroughly? if so,please note it at readme

qiuzhongrun commented 8 months ago

still no solution?

xhd2015 commented 3 months ago

Gophers, if you repeatedly encounter this problem, that demonstrate one thing: gomonkey is hard to get started. We now can try https://github.com/xhd2015/xgo as a brand new replacement.