agiledragon / gomonkey

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

Private method tests fail on Linux/Arm64 #159

Open myzhan opened 5 months ago

myzhan commented 5 months ago

I try to run tests on armbian, running on a RK3566 soc. Only the private method tests fail.

Go version: 1.21.6

myzhan commented 5 months ago

Ah, I ran the tests with "-gcflags=-l", I should try "-gcflags=all=-l"

myzhan commented 3 months ago

I tried "-gcflags=all=-l" and met failure.

Running tool: /home/myzhan/local/go/bin/go test -timeout 30s -coverprofile=/tmp/vscode-gotFUMeL/go-code-cover -run ^TestApplyPrivateMethod$ github.com/agiledragon/gomonkey/v2/test -gcflags=all=-l

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

goroutine 18 [running]: runtime.throw({0x2300e1?, 0x8?}) /home/myzhan/local/go/src/runtime/panic.go:1077 +0x40 fp=0x4000165170 sp=0x4000165140 pc=0x4fab0 runtime.sigpanic() /home/myzhan/local/go/src/runtime/signal_unix.go:875 +0x198 fp=0x40001651a0 sp=0x4000165170 pc=0x66ae8 runtime.memmove() /home/myzhan/local/go/src/runtime/memmove_arm64.s:65 +0x60 fp=0x40001651b0 sp=0x40001651b0 pc=0x85230 fmt.(buffer).writeString(0x4000118820, {0x824ff049a4f2e7f9?, 0x7?}) /home/myzhan/local/go/src/fmt/print.go:108 +0x8c fp=0x4000165200 sp=0x40001651b0 pc=0xf595c fmt.(fmt).padString(0x4000118800?, {0x824ff049a4f2e7f9?, 0x4?}) /home/myzhan/local/go/src/fmt/format.go:110 +0xac fp=0x4000165230 sp=0x4000165200 pc=0xf3d5c fmt.(fmt).fmtS(0x4000165200?, {0x824ff049a4f2e7f9?, 0x40001652e8?}) /home/myzhan/local/go/src/fmt/format.go:359 +0x34 fp=0x4000165260 sp=0x4000165230 pc=0xf48e4 fmt.(pp).fmtString(0xd00000001eafa0?, {0x824ff049a4f2e7f9?, 0x7fa2eb8a68?}, 0x9e3bc?) /home/myzhan/local/go/src/fmt/print.go:494 +0x8c fp=0x40001652a0 sp=0x4000165260 pc=0xf6e5c fmt.(pp).printArg(0x4000118820, {0x1e7540?, 0x400010c900}, 0x76) /home/myzhan/local/go/src/fmt/print.go:741 +0xf8 fp=0x4000165310 sp=0x40001652a0 pc=0xf7cb8 fmt.(pp).doPrintf(0x4000118820, {0x22fc81, 0x2}, {0x40001654b0?, 0x1, 0x1}) /home/myzhan/local/go/src/fmt/print.go:1077 +0x244 fp=0x40001653c0 sp=0x4000165310 pc=0xf94c4 fmt.Sprintf({0x22fc81, 0x2}, {0x40001654b0, 0x1, 0x1}) /home/myzhan/local/go/src/fmt/print.go:239 +0x4c fp=0x4000165420 sp=0x40001653c0 pc=0xf605c github.com/smartystreets/assertions.shouldEqual({0x1e7540?, 0x400010c900}, {0x1e7540?, 0x252d48}) /home/myzhan/go/pkg/mod/github.com/smartystreets/assertions@v0.0.0-20180927180507-b2de0cb4f26d/equality.go:43 +0x228 fp=0x4000165560 sp=0x4000165420 pc=0x1ad358 github.com/smartystreets/assertions.ShouldEqual({0x1e7540, 0x400010c900}, {0x400010c910?, 0x1, 0x7fa2eb8a68?}) /home/myzhan/go/pkg/mod/github.com/smartystreets/assertions@v0.0.0-20180927180507-b2de0cb4f26d/equality.go:24 +0x68 fp=0x40001655a0 sp=0x4000165560 pc=0x1ad0c8 github.com/smartystreets/goconvey/convey.(context).So(0x3afc00?, {0x1e7540?, 0x400010c900?}, 0x1bba2c?, {0x400010c910?, 0x1ead40?, 0x242e01?}) /home/myzhan/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:173 +0x48 fp=0x40001655e0 sp=0x40001655a0 pc=0x1b5168 github.com/smartystreets/goconvey/convey.So({0x1e7540, 0x400010c900}, 0x22fbff?, {0x400010c910, 0x1, 0x1}) /home/myzhan/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/doc.go:125 +0x50 fp=0x4000165630 sp=0x40001655e0 pc=0x1b6390 github.com/agiledragon/gomonkey/v2/test.TestApplyPrivateMethod.func1.1() /home/myzhan/sdcard/github/gomonkey/test/apply_private_method_test.go:23 +0xc4 fp=0x40001656a0 sp=0x4000165630 pc=0x1bba64 github.com/smartystreets/goconvey/convey.parseAction.func1({0x23f654, 0x35}) /home/myzhan/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/discovery.go:80 +0x24 fp=0x40001656b0 sp=0x40001656a0 pc=0x1b61c4 github.com/smartystreets/goconvey/convey.(context).conveyInner(0x40001202a0, {0x23f654?, 0x4000130360?}, 0x400010c8e0) /home/myzhan/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:261 +0x15c fp=0x4000165740 sp=0x40001656b0 pc=0x1b564c github.com/smartystreets/goconvey/convey.(context).Convey.func1() /home/myzhan/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:163 +0x30 fp=0x4000165770 sp=0x4000165740 pc=0x1b5090 github.com/jtolds/gls.(ContextManager).SetValues.func1(0x0) /home/myzhan/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/context.go:97 +0x330 fp=0x40001658e0 sp=0x4000165770 pc=0x1ae440 github.com/jtolds/gls.EnsureGoroutineId(0x400010e870) /home/myzhan/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/gid.go:19 +0xe8 fp=0x4000165940 sp=0x40001658e0 pc=0x1ae818 github.com/jtolds/gls.(ContextManager).SetValues(0x400010c500, 0x400010e810, 0x40001160f0) /home/myzhan/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/context.go:63 +0x150 fp=0x4000165980 sp=0x4000165940 pc=0x1ae0c0 github.com/smartystreets/goconvey/convey.(context).Convey(0x4000120240, {0x4000109a68?, 0x4000109a68?, 0x1b1c14?}) /home/myzhan/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:162 +0x3b8 fp=0x4000165a10 sp=0x4000165980 pc=0x1b5028 github.com/smartystreets/goconvey/convey.Convey({0x4000109a68, 0x2, 0x2}) /home/myzhan/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/doc.go:77 +0x3c fp=0x4000165a40 sp=0x4000165a10 pc=0x1b62fc github.com/agiledragon/gomonkey/v2/test.TestApplyPrivateMethod.func1() /home/myzhan/sdcard/github/gomonkey/test/apply_private_method_test.go:15 +0x60 fp=0x4000165a90 sp=0x4000165a40 pc=0x1bbe90 github.com/smartystreets/goconvey/convey.parseAction.func1({0x2354e3, 0x16}) /home/myzhan/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/discovery.go:80 +0x24 fp=0x4000165aa0 sp=0x4000165a90 pc=0x1b61c4 github.com/smartystreets/goconvey/convey.(context).conveyInner(0x4000120240, {0x2354e3?, 0x7700000000000000?}, 0x400010c8b0) /home/myzhan/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:261 +0x15c fp=0x4000165b30 sp=0x4000165aa0 pc=0x1b564c github.com/smartystreets/goconvey/convey.rootConvey.func1() /home/myzhan/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:110 +0xcc fp=0x4000165bb0 sp=0x4000165b30 pc=0x1b4a4c github.com/jtolds/gls.(ContextManager).SetValues.func1(0x0) /home/myzhan/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/context.go:97 +0x330 fp=0x4000165d20 sp=0x4000165bb0 pc=0x1ae440 github.com/jtolds/gls.EnsureGoroutineId.func1() /home/myzhan/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/gid.go:24 +0x2c fp=0x4000165d40 sp=0x4000165d20 pc=0x1ae87c github.com/jtolds/gls._m(0x4000109d98?, 0x1ae7ac?) /home/myzhan/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/stack_tags.go:108 +0x28 fp=0x4000165d60 sp=0x4000165d40 pc=0x1af408 github.com/jtolds/gls.github_com_jtolds_gls_markS(0x3af101?, 0x4000109d80?) /home/myzhan/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/stack_tags.go:56 +0x1c fp=0x4000165d80 sp=0x4000165d60 pc=0x1aeeac github.com/jtolds/gls.addStackTag(0x3af140?, 0x400010e720?) /home/myzhan/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/stack_tags.go:49 +0x20 fp=0x4000165da0 sp=0x4000165d80 pc=0x1aee50 github.com/jtolds/gls.EnsureGoroutineId(0x400010e720) /home/myzhan/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/gid.go:24 +0xc0 fp=0x4000165e00 sp=0x4000165da0 pc=0x1ae7f0 github.com/jtolds/gls.(ContextManager).SetValues(0x400010c500, 0x400010e6c0, 0x40001420a0) /home/myzhan/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/context.go:63 +0x150 fp=0x4000165e40 sp=0x4000165e00 pc=0x1ae0c0 github.com/smartystreets/goconvey/convey.rootConvey({0x4000109f28?, 0x0?, 0x4000109f18?}) /home/myzhan/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:105 +0x224 fp=0x4000165ed0 sp=0x4000165e40 pc=0x1b4944 github.com/smartystreets/goconvey/convey.Convey({0x4000109f28, 0x3, 0x3}) /home/myzhan/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/doc.go:75 +0x50 fp=0x4000165f00 sp=0x4000165ed0 pc=0x1b6310 github.com/agiledragon/gomonkey/v2/test.TestApplyPrivateMethod(0x0?) /home/myzhan/sdcard/github/gomonkey/test/apply_private_method_test.go:14 +0x74 fp=0x4000165f60 sp=0x4000165f00 pc=0x1bb344 testing.tRunner(0x4000122820, 0x242b70) /home/myzhan/local/go/src/testing/testing.go:1595 +0xf8 fp=0x4000165fb0 sp=0x4000165f60 pc=0x159a88 testing.(T).Run.func1() /home/myzhan/local/go/src/testing/testing.go:1648 +0x2c fp=0x4000165fd0 sp=0x4000165fb0 pc=0x15a73c runtime.goexit() /home/myzhan/local/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x4000165fd0 sp=0x4000165fd0 pc=0x84934 created by testing.(*T).Run in goroutine 1 /home/myzhan/local/go/src/testing/testing.go:1648 +0x318

agiledragon commented 3 weeks ago

@wiselike go1.21.6 + Only the private method tests fail. I think you can fix it this month :)

wiselike commented 2 weeks ago

what's your command? I tried to run make test and all get passwd. @myzhan

alpha-baby commented 2 weeks ago

on my linux/arm64, unit test failed

run with command:

make test

log: test.log

myzhan commented 2 weeks ago

what's your command? I tried to run make test and all get passwd. @myzhan

I ran "make test".