Comments (6)
same problem vv2.11.0, processor: m3pro
+1
@wustrong @shubham-dogra-pingsafe 已经有项目用xgo验证可以兼容M2,M3,参考: kilianc/base-golang#3
xgo使用:https://github.com/xhd2015/xgo .
from gomonkey.
Can you post the complete program?
from gomonkey.
- Environment:
- Apple M1
- go1.20.12
- github.com/agiledragon/gomonkey/[email protected]
- Function Codes
package main
func main() {
_, _, _ = Execute()
}
func Execute() (int, int, int) {
s := S{}
return F1(), F2(), s.F3()
}
func F1() int {
return 1
}
func F2() int {
return 2
}
type S struct {
}
func (*S) F3() int {
return 3
}
- Works with one patch
package main_test
import (
"github.com/agiledragon/gomonkey/v2"
"github.com/go-playground/assert/v2"
"gomonkey_arm64"
"testing"
)
func TestExecute(t *testing.T) {
rst1Expect := 11
gomonkey.
ApplyFunc(main.F1, func() int {
return rst1Expect
})
rst1, _, _ := main.Execute()
assert.Equal(t, rst1Expect, rst1)
}
- Fail with multi ApplyFunc/Method
It can work with the env
GOARCH=amd64
package main_test
import (
"github.com/agiledragon/gomonkey/v2"
"github.com/go-playground/assert/v2"
"gomonkey_arm64"
"reflect"
"testing"
)
func TestExecute(t *testing.T) {
s := main.S{}
rst1Expect := 11
rst2Expect := 12
rst3Expect := 13
gomonkey.
ApplyFunc(main.F1, func() int {
return rst1Expect
}).
ApplyFunc(main.F2, func() int {
return rst2Expect
}).
ApplyMethod(reflect.TypeOf(&s), "F3", func(_ *main.S) int {
return rst3Expect
})
rst1, rst2, rst3 := main.Execute()
assert.Equal(t, rst1Expect, rst1)
assert.Equal(t, rst2Expect, rst2)
assert.Equal(t, rst3Expect, rst3)
}
/Users/jinzheng/go/go1.20.12/bin/go tool test2json -t /Users/jinzheng/Library/Caches/JetBrains/GoLand2023.3/tmp/GoLand/___1TestExecute_in_gomonkey_arm64.test -test.v -test.paniconexit0 -test.run ^\QTestExecute\E$
=== RUN TestExecute
unexpected fault address 0x10052fa08
fatal error: fault
[signal SIGBUS: bus error code=0x1 addr=0x10052fa08 pc=0x10052fa08]
goroutine 6 [running]:
runtime.throw({0x100531d07?, 0x10052dde8?})
/Users/jinzheng/go/go1.20.12/src/runtime/panic.go:1047 +0x40 fp=0x14000070c50 sp=0x14000070c20 pc=0x1003f4100
runtime.sigpanic()
/Users/jinzheng/go/go1.20.12/src/runtime/signal_unix.go:838 +0x10c fp=0x14000070c80 sp=0x14000070c50 pc=0x10040af1c
github.com/agiledragon/gomonkey/v2.write(0x10052da50, 0x1400001a120, 0x18, 0x10052c000, 0x4000, 0x5)
/Users/jinzheng/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/write_darwin_arm64.s:36 +0x1028 fp=0x14000070cc0 sp=0x14000070c90 pc=0x10052fa08
github.com/agiledragon/gomonkey/v2.modifyBinary(0x18?, {0x1400001a120, 0x18, 0x18})
/Users/jinzheng/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/modify_binary_darwin.go:16 +0x78 fp=0x14000070d30 sp=0x14000070cc0 pc=0x10052dee8
github.com/agiledragon/gomonkey/v2.replace(0x100567d40?, 0x14000016340?)
/Users/jinzheng/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/patch.go:269 +0x74 fp=0x14000070da0 sp=0x14000070d30 pc=0x10052e874
github.com/agiledragon/gomonkey/v2.(*Patches).ApplyCore(0x1400000c0d8, {0x100567d40?, 0x1005a2ac0?, 0x140000745d0?}, {0x100567d40, 0x14000016340, 0x13})
/Users/jinzheng/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/patch.go:213 +0x74 fp=0x14000070e20 sp=0x14000070da0 pc=0x10052e314
github.com/agiledragon/gomonkey/v2.(*Patches).ApplyFunc(0x14000070ec8?, {0x100567d40?, 0x1005a2ac0?}, {0x100567d40, 0x14000016340})
/Users/jinzheng/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/patch.go:83 +0x70 fp=0x14000070e90 sp=0x14000070e20 pc=0x10052e110
github.com/agiledragon/gomonkey/v2.ApplyFunc({0x100567d40, 0x1005a2ac0}, {0x100567d40, 0x14000016340})
/Users/jinzheng/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/patch.go:25 +0x40 fp=0x14000070ed0 sp=0x14000070e90 pc=0x10052dfb0
gomonkey_arm64_test.TestExecute(0x0?)
/Users/jinzheng/Projects/Personal/gomonkey_test/main_test.go:17 +0x5c fp=0x14000070f60 sp=0x14000070ed0 pc=0x1005310ac
testing.tRunner(0x14000003a00, 0x1005a2ad0)
/Users/jinzheng/go/go1.20.12/src/testing/testing.go:1576 +0x114 fp=0x14000070fb0 sp=0x14000070f60 pc=0x1004b4554
testing.(*T).Run.func1()
/Users/jinzheng/go/go1.20.12/src/testing/testing.go:1629 +0x2c fp=0x14000070fd0 sp=0x14000070fb0 pc=0x1004b525c
runtime.goexit()
/Users/jinzheng/go/go1.20.12/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000070fd0 sp=0x14000070fd0 pc=0x100427b04
created by testing.(*T).Run
/Users/jinzheng/go/go1.20.12/src/testing/testing.go:1629 +0x340
goroutine 1 [chan receive]:
runtime.gopark(0x1005a2d30, 0x1400005e138, 0xe, 0x17, 0x2)
/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:381 +0xd8 fp=0x14000105aa0 sp=0x14000105a70 pc=0x1003f6938
runtime.chanrecv(0x1400005e0e0, 0x14000105baf, 0x1)
/Users/jinzheng/go/go1.20.12/src/runtime/chan.go:583 +0x29c fp=0x14000105b30 sp=0x14000105aa0 pc=0x1003c208c
runtime.chanrecv1(0x10059f5c0?, 0x100569480?)
/Users/jinzheng/go/go1.20.12/src/runtime/chan.go:442 +0x14 fp=0x14000105b60 sp=0x14000105b30 pc=0x1003c1db4
testing.(*T).Run(0x14000003860, {0x100533366, 0xb}, 0x1005a2ad0)
/Users/jinzheng/go/go1.20.12/src/testing/testing.go:1630 +0x354 fp=0x14000105c20 sp=0x14000105b60 pc=0x1004b5124
testing.runTests.func1(0x14000105c01?)
/Users/jinzheng/go/go1.20.12/src/testing/testing.go:2036 +0x48 fp=0x14000105c70 sp=0x14000105c20 pc=0x1004b6e18
testing.tRunner(0x14000003860, 0x14000105d68)
/Users/jinzheng/go/go1.20.12/src/testing/testing.go:1576 +0x114 fp=0x14000105cc0 sp=0x14000105c70 pc=0x1004b4554
testing.runTests(0x1400010e0a0?, {0x1006b6720, 0x1, 0x1}, {0x100534642?, 0xf?, 0x0?})
/Users/jinzheng/go/go1.20.12/src/testing/testing.go:2034 +0x334 fp=0x14000105d90 sp=0x14000105cc0 pc=0x1004b6d24
testing.(*M).Run(0x1400010e0a0)
/Users/jinzheng/go/go1.20.12/src/testing/testing.go:1906 +0x458 fp=0x14000105ef0 sp=0x14000105d90 pc=0x1004b5b48
main.main()
_testmain.go:49 +0x80 fp=0x14000105f70 sp=0x14000105ef0 pc=0x100531380
runtime.main()
/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:250 +0x21c fp=0x14000105fd0 sp=0x14000105f70 pc=0x1003f64fc
runtime.goexit()
/Users/jinzheng/go/go1.20.12/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000105fd0 sp=0x14000105fd0 pc=0x100427b04
goroutine 2 [force gc (idle)]:
runtime.gopark(0x1005a2f28, 0x1006bf100, 0x11, 0x14, 0x1)
/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:381 +0xd8 fp=0x14000046f70 sp=0x14000046f40 pc=0x1003f6938
runtime.goparkunlock(0x0?, 0x0?, 0x0?, 0x0?)
/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:387 +0x34 fp=0x14000046fa0 sp=0x14000046f70 pc=0x1003f69c4
runtime.forcegchelper()
/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:305 +0xb4 fp=0x14000046fd0 sp=0x14000046fa0 pc=0x1003f6754
runtime.goexit()
/Users/jinzheng/go/go1.20.12/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000046fd0 sp=0x14000046fd0 pc=0x100427b04
created by runtime.init.6
/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:293 +0x24
goroutine 3 [GC sweep wait]:
runtime.gopark(0x1005a2f28, 0x1006bf520, 0xc, 0x14, 0x1)
/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:381 +0xd8 fp=0x14000047740 sp=0x14000047710 pc=0x1003f6938
runtime.goparkunlock(0x0?, 0x0?, 0x0?, 0x0?)
/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:387 +0x34 fp=0x14000047770 sp=0x14000047740 pc=0x1003f69c4
runtime.bgsweep(0x0?)
/Users/jinzheng/go/go1.20.12/src/runtime/mgcsweep.go:278 +0xa0 fp=0x140000477b0 sp=0x14000047770 pc=0x1003e05c0
runtime.gcenable.func1()
/Users/jinzheng/go/go1.20.12/src/runtime/mgc.go:178 +0x28 fp=0x140000477d0 sp=0x140000477b0 pc=0x1003d56b8
runtime.goexit()
/Users/jinzheng/go/go1.20.12/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000477d0 sp=0x140000477d0 pc=0x100427b04
created by runtime.gcenable
/Users/jinzheng/go/go1.20.12/src/runtime/mgc.go:178 +0x74
goroutine 4 [GC scavenge wait]:
runtime.gopark(0x1005a2f28, 0x1006bf6c0, 0xd, 0x14, 0x2)
/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:381 +0xd8 fp=0x14000047f20 sp=0x14000047ef0 pc=0x1003f6938
runtime.goparkunlock(0x1400005e000?, 0x78?, 0xcf?, 0x1?)
/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:387 +0x34 fp=0x14000047f50 sp=0x14000047f20 pc=0x1003f69c4
runtime.(*scavengerState).park(0x1006bf6c0)
/Users/jinzheng/go/go1.20.12/src/runtime/mgcscavenge.go:400 +0x4c fp=0x14000047f80 sp=0x14000047f50 pc=0x1003de2ac
runtime.bgscavenge(0x0?)
/Users/jinzheng/go/go1.20.12/src/runtime/mgcscavenge.go:628 +0x44 fp=0x14000047fb0 sp=0x14000047f80 pc=0x1003de7f4
runtime.gcenable.func2()
/Users/jinzheng/go/go1.20.12/src/runtime/mgc.go:179 +0x28 fp=0x14000047fd0 sp=0x14000047fb0 pc=0x1003d5658
runtime.goexit()
/Users/jinzheng/go/go1.20.12/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000047fd0 sp=0x14000047fd0 pc=0x100427b04
created by runtime.gcenable
/Users/jinzheng/go/go1.20.12/src/runtime/mgc.go:179 +0xb8
goroutine 5 [finalizer wait]:
runtime.gopark(0x1005a2d98, 0x1006f3498, 0x10, 0x14, 0x1)
/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:381 +0xd8 fp=0x14000046580 sp=0x14000046550 pc=0x1003f6938
runtime.runfinq()
/Users/jinzheng/go/go1.20.12/src/runtime/mfinal.go:193 +0xf4 fp=0x140000467d0 sp=0x14000046580 pc=0x1003d4874
runtime.goexit()
/Users/jinzheng/go/go1.20.12/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000467d0 sp=0x140000467d0 pc=0x100427b04
created by runtime.createfing
/Users/jinzheng/go/go1.20.12/src/runtime/mfinal.go:163 +0x4c
from gomonkey.
same problem
from gomonkey.
same problem vv2.11.0, processor: m3pro
from gomonkey.
same problem vv2.11.0, processor: m3pro
+1
from gomonkey.
Related Issues (20)
- 是否有人用gomonkey来实现游戏服务器热更新?
- Why ApplyFunc mocked func returns the same result in a for loop? HOT 1
- MacOS 上的 permission denied 问题,也可能和 cgo 有关 HOT 8
- why patches.Reset not effective? HOT 1
- panic with SIGBUS HOT 7
- MacOS ARM64 兼容性问题 HOT 6
- 打桩的方法内仅执行 return 语句,打桩没有生效 HOT 2
- panic: runtime error: index out of range [0] with length 0 [darwin/arm64] [M1] HOT 8
- how to mock func which as a param in another func HOT 1
- mac os m1 ApplyFuncReturn not work and unit test many panic HOT 5
- i solve it successfully in mac M1 by update new gomonkey version for permission deny error HOT 3
- 内联优化导致apply func失效 HOT 3
- gomonkey 中有异步携程时,mock的方法会失效 HOT 3
- Private method tests fail on Linux/Arm64 HOT 2
- Is it possible to add a `init` func to check whether `-gcflags=all=-l` is in `os.Args`? HOT 1
- gomonky 为泛型结构体的方法打桩不生效 HOT 2
- Running multiple cases at the same time and reporting errors: panic: double seq is less than call seq HOT 2
- Intellij IDEA中,如何对所有go test命令都设置`-gcflags=all=-l`参数? HOT 1
- 获取测试覆盖率失败 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gomonkey.