-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Occasionally triggers a SIGBUS: bus error
To Reproduce
package main
import (
"testing"
"github.com/bytedance/mockey"
"github.com/smartystreets/goconvey/convey"
)
var i int = 0
func FuncX() int {
return i
}
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)
})
}
run for i in {1..100} ; do go test -v -gcflags="all=-N -l" -count=1 *.go || break; done
go test -v -gcflags="all=-N -l" -count=2 . ✔SIGBUS: bus error
PC=0x1011b5b54 m=1 sigcode=1 addr=0x1011b5b54
goroutine 0 gp=0x14000002540 m=1 mp=0x14000054008 [idle]:
runtime.nanotime1()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/sys_darwin.go:337 +0x24 fp=0x16ee9ae10 sp=0x16ee9ade0 pc=0x101047cd4
runtime.nanotime()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/time_nofake.go:19 +0x10 fp=0x16ee9ae30 sp=0x16ee9ae10 pc=0x10104a4e0
runtime.sysmon()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:5982 +0xc4 fp=0x16ee9aeb0 sp=0x16ee9ae30 pc=0x1010357c4
runtime.mstart1()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:1729 +0x88 fp=0x16ee9aee0 sp=0x16ee9aeb0 pc=0x10102d848
runtime.mstart0()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:1686 +0x6c fp=0x16ee9af10 sp=0x16ee9aee0 pc=0x10102d79c
runtime.mstart()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/asm_arm64.s:128 +0x10 fp=0x16ee9af20 sp=0x16ee9af10 pc=0x10105c480
goroutine 1 gp=0x140000021c0 m=nil [chan receive]:
runtime.gopark(0x10121cbc8, 0x140001700c8, 0xe, 0x7, 0x2)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:402 +0xe0 fp=0x14000027400 sp=0x140000273d0 pc=0x10102ae90
runtime.chanrecv(0x14000170070, 0x14000027506, 0x1)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/chan.go:583 +0x26c fp=0x14000027480 sp=0x14000027400 pc=0x100ff331c
runtime.chanrecv1(0x101331080?, 0x1011e8c40?)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/chan.go:442 +0x14 fp=0x140000274b0 sp=0x14000027480 pc=0x100ff30a4
testing.(*T).Run(0x14000132820, {0x1011b7624, 0x9}, 0x10121caa0)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/testing/testing.go:1750 +0x688 fp=0x140000276d0 sp=0x140000274b0 pc=0x10110daf8
testing.runTests.func1(0x14000132680)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/testing/testing.go:2161 +0x98 fp=0x14000027770 sp=0x140000276d0 pc=0x1011110b8
testing.tRunner(0x14000132680, 0x14000027948)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/testing/testing.go:1689 +0x1a8 fp=0x14000027860 sp=0x14000027770 pc=0x10110c4c8
testing.runTests(0x14000140018, {0x10131c1c0, 0x1, 0x1}, {0xc1b0c3a9c1315fc8, 0x8bb2d65599, 0x1013313c0})
/opt/homebrew/Cellar/go/1.22.5/libexec/src/testing/testing.go:2159 +0x444 fp=0x14000027990 sp=0x14000027860 pc=0x101110f04
testing.(*M).Run(0x140001220a0)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/testing/testing.go:2027 +0xb08 fp=0x14000027ed0 sp=0x14000027990 pc=0x10110ee18
main.main()
_testmain.go:47 +0x98 fp=0x14000027f60 sp=0x14000027ed0 pc=0x1011b5a58
runtime.main()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:271 +0x228 fp=0x14000027fd0 sp=0x14000027f60 pc=0x10102aa38
runtime.goexit({})
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/asm_arm64.s:1222 +0x4 fp=0x14000027fd0 sp=0x14000027fd0 pc=0x10105e904
goroutine 2 gp=0x14000002700 m=nil [force gc (idle)]:
runtime.gopark(0x10121ced0, 0x101330db0, 0x11, 0xa, 0x1)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:402 +0xe0 fp=0x1400004ef70 sp=0x1400004ef40 pc=0x10102ae90
runtime.goparkunlock(0x101330db0?, 0x0?, 0x0?, 0x0?)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:408 +0x34 fp=0x1400004efa0 sp=0x1400004ef70 pc=0x10102af24
runtime.forcegchelper()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:326 +0xb4 fp=0x1400004efd0 sp=0x1400004efa0 pc=0x10102acb4
runtime.goexit({})
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/asm_arm64.s:1222 +0x4 fp=0x1400004efd0 sp=0x1400004efd0 pc=0x10105e904
created by runtime.init.6 in goroutine 1
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:314 +0x24
goroutine 3 gp=0x14000002c40 m=nil [GC sweep wait]:
runtime.gopark(0x10121ced0, 0x1013310c0, 0xc, 0x9, 0x1)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:402 +0xe0 fp=0x1400004f740 sp=0x1400004f710 pc=0x10102ae90
runtime.goparkunlock(0x1013310c0?, 0x0?, 0x0?, 0x0?)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:408 +0x34 fp=0x1400004f770 sp=0x1400004f740 pc=0x10102af24
runtime.bgsweep(0x14000068000)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/mgcsweep.go:278 +0x9c fp=0x1400004f7b0 sp=0x1400004f770 pc=0x10101440c
runtime.gcenable.gowrap1()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/mgc.go:203 +0x28 fp=0x1400004f7d0 sp=0x1400004f7b0 pc=0x101008db8
runtime.goexit({})
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/asm_arm64.s:1222 +0x4 fp=0x1400004f7d0 sp=0x1400004f7d0 pc=0x10105e904
created by runtime.gcenable in goroutine 1
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/mgc.go:203 +0x6c
goroutine 17 gp=0x14000084380 m=nil [GC scavenge wait]:
runtime.gopark(0x10121ced0, 0x101331560, 0xd, 0xa, 0x2)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:402 +0xe0 fp=0x1400004a720 sp=0x1400004a6f0 pc=0x10102ae90
runtime.goparkunlock(0x101331560?, 0xf0?, 0x36?, 0x1?)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:408 +0x34 fp=0x1400004a750 sp=0x1400004a720 pc=0x10102af24
runtime.(*scavengerState).park(0x101331560)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/mgcscavenge.go:425 +0x4c fp=0x1400004a780 sp=0x1400004a750 pc=0x101011a5c
runtime.bgscavenge(0x14000068000)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/mgcscavenge.go:653 +0x44 fp=0x1400004a7b0 sp=0x1400004a780 pc=0x101011f94
runtime.gcenable.gowrap2()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/mgc.go:204 +0x28 fp=0x1400004a7d0 sp=0x1400004a7b0 pc=0x101008d58
runtime.goexit({})
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/asm_arm64.s:1222 +0x4 fp=0x1400004a7d0 sp=0x1400004a7d0 pc=0x10105e904
created by runtime.gcenable in goroutine 1
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/mgc.go:204 +0xac
goroutine 33 gp=0x14000104380 m=nil [finalizer wait]:
runtime.gopark(0x10121cc20, 0x101397050, 0x10, 0xa, 0x1)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:402 +0xe0 fp=0x1400004e590 sp=0x1400004e560 pc=0x10102ae90
runtime.runfinq()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/mfinal.go:194 +0xf0 fp=0x1400004e7d0 sp=0x1400004e590 pc=0x101007f50
runtime.goexit({})
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/asm_arm64.s:1222 +0x4 fp=0x1400004e7d0 sp=0x1400004e7d0 pc=0x10105e904
created by runtime.createfing in goroutine 1
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/mfinal.go:164 +0x4c
goroutine 34 gp=0x14000104540 m=0 mp=0x101331f60 [stopping the world]:
runtime.systemstack_switch()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/asm_arm64.s:200 +0x8 fp=0x140001968a0 sp=0x14000196890 pc=0x10105c508
runtime.stopTheWorld(0x10)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/proc.go:1343 +0x8c fp=0x140001968e0 sp=0x140001968a0 pc=0x10102cedc
github.com/bytedance/mockey/internal/monkey/common/runtime_link/stw.(*stwCtx).StopTheWorld(0x14000200000)
/usr/local/lib/go/pkg/mod/github.com/bytedance/[email protected]/internal/monkey/common/runtime_link/stw/stw_1_22.go:37 +0x24 fp=0x14000196910 sp=0x140001968e0 pc=0x1011ae304
github.com/bytedance/mockey/internal/monkey/mem.WriteWithSTW(0x1011b5660, {0x101458000, 0x18, 0x4000})
/usr/local/lib/go/pkg/mod/github.com/bytedance/[email protected]/internal/monkey/mem/write.go:29 +0x50 fp=0x14000196a40 sp=0x14000196910 pc=0x1011ae530
github.com/bytedance/mockey/internal/monkey.(*Patch).Unpatch(0x1400011aab0)
/usr/local/lib/go/pkg/mod/github.com/bytedance/[email protected]/internal/monkey/patch.go:38 +0x70 fp=0x14000196ab0 sp=0x14000196a40 pc=0x1011b0cd0
github.com/bytedance/mockey.(*Mocker).UnPatch(0x1400012d1e0)
/usr/local/lib/go/pkg/mod/github.com/bytedance/[email protected]/mock.go:344 +0xd8 fp=0x14000196b50 sp=0x14000196ab0 pc=0x1011b4478
github.com/bytedance/mockey.(*Mocker).unPatch(0x1400012d1e0)
/usr/local/lib/go/pkg/mod/github.com/bytedance/[email protected]/mock.go:440 +0x20 fp=0x14000196b70 sp=0x14000196b50 pc=0x1011b4750
github.com/bytedance/mockey.PatchConvey.func1.1()
/usr/local/lib/go/pkg/mod/github.com/bytedance/[email protected]/convey.go:39 +0xb8 fp=0x14000196c20 sp=0x14000196b70 pc=0x1011b5248
runtime.deferreturn()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/panic.go:602 +0x60 fp=0x14000196cb0 sp=0x14000196c20 pc=0x101027490
github.com/bytedance/mockey.PatchConvey.func1({0x101396f60, 0x0, 0x0})
/usr/local/lib/go/pkg/mod/github.com/bytedance/[email protected]/convey.go:43 +0x144 fp=0x14000196d90 sp=0x14000196cb0 pc=0x1011b1904
reflect.callReflect(0x1400011a720, 0x140001855c8, 0x14000197428, 0x14000197430)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/reflect/value.go:782 +0x498 fp=0x140001973d0 sp=0x14000196d90 pc=0x1010cd6b8
reflect.callReflect(0x1400011a720, 0x140001855c8, 0x14000185428, 0x14000185430)
<autogenerated>:1 +0x28 fp=0x14000197400 sp=0x140001973d0 pc=0x1010dad68
reflect.makeFuncStub()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/reflect/asm_arm64.s:48 +0x58 fp=0x140001975c0 sp=0x14000197400 pc=0x1010da0c8
github.com/smartystreets/goconvey/convey.parseAction.func1({0x10121fed0, 0x1400012e180})
/usr/local/lib/go/pkg/mod/github.com/smartystreets/[email protected]/convey/discovery.go:80 +0x30 fp=0x140001975e0 sp=0x140001975c0 pc=0x1011aa930
github.com/smartystreets/goconvey/convey.(*context).conveyInner(0x1400012e180, {0x1011c11a3, 0x2a}, 0x14000119400)
/usr/local/lib/go/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:261 +0x29c fp=0x14000197770 sp=0x140001975e0 pc=0x1011a94ac
github.com/smartystreets/goconvey/convey.rootConvey.func1()
/usr/local/lib/go/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:110 +0x1a4 fp=0x14000197870 sp=0x14000197770 pc=0x1011a88b4
github.com/jtolds/gls.(*ContextManager).SetValues.func1(0x0)
/usr/local/lib/go/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:97 +0x528 fp=0x14000197a90 sp=0x14000197870 pc=0x10119fba8
github.com/jtolds/gls.EnsureGoroutineId.func1()
/usr/local/lib/go/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:24 +0x34 fp=0x14000197ac0 sp=0x14000197a90 pc=0x1011a0244
github.com/jtolds/gls._m(0x0, 0x140001400c0)
/usr/local/lib/go/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:108 +0x34 fp=0x14000197ae0 sp=0x14000197ac0 pc=0x1011a0e84
github.com/jtolds/gls.github_com_jtolds_gls_markS(0x0, 0x140001400c0)
/usr/local/lib/go/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:56 +0x24 fp=0x14000197b00 sp=0x14000197ae0 pc=0x1011a0924
github.com/jtolds/gls.addStackTag(0x0, 0x140001400c0)
/usr/local/lib/go/pkg/mod/github.com/jtolds/[email protected]+incompatible/stack_tags.go:49 +0x2c fp=0x14000197b20 sp=0x14000197b00 pc=0x1011a08cc
github.com/jtolds/gls.EnsureGoroutineId(0x1400011a840)
/usr/local/lib/go/pkg/mod/github.com/jtolds/[email protected]+incompatible/gid.go:24 +0x180 fp=0x14000197be0 sp=0x14000197b20 pc=0x1011a01d0
github.com/jtolds/gls.(*ContextManager).SetValues(0x140001184c0, 0x1400011a7e0, 0x14000156060)
/usr/local/lib/go/pkg/mod/github.com/jtolds/[email protected]+incompatible/context.go:63 +0x254 fp=0x14000197c30 sp=0x14000197be0 pc=0x10119f644
github.com/smartystreets/goconvey/convey.rootConvey({0x14000185e70, 0x3, 0x3})
/usr/local/lib/go/pkg/mod/github.com/smartystreets/[email protected]/convey/context.go:105 +0x394 fp=0x14000197d10 sp=0x14000197c30 pc=0x1011a86d4
github.com/smartystreets/goconvey/convey.Convey({0x14000185e70, 0x3, 0x3})
/usr/local/lib/go/pkg/mod/github.com/smartystreets/[email protected]/convey/doc.go:75 +0x58 fp=0x14000197d50 sp=0x14000197d10 pc=0x1011aab68
github.com/bytedance/mockey.PatchConvey({0x14000185e70, 0x3, 0x3})
/usr/local/lib/go/pkg/mod/github.com/bytedance/[email protected]/convey.go:48 +0x21c fp=0x14000197e20 sp=0x14000197d50 pc=0x1011b177c
command-line-arguments.TestCount(0x14000132820)
/Users/jialiu/tmp/1726123276/count_test.go:17 +0x12c fp=0x14000197eb0 sp=0x14000197e20 pc=0x1011b57bc
testing.tRunner(0x14000132820, 0x10121caa0)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/testing/testing.go:1689 +0x1a8 fp=0x14000197fa0 sp=0x14000197eb0 pc=0x10110c4c8
testing.(*T).Run.gowrap1()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/testing/testing.go:1742 +0x38 fp=0x14000197fd0 sp=0x14000197fa0 pc=0x10110dce8
runtime.goexit({})
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/asm_arm64.s:1222 +0x4 fp=0x14000197fd0 sp=0x14000197fd0 pc=0x10105e904
created by testing.(*T).Run in goroutine 1
/opt/homebrew/Cellar/go/1.22.5/libexec/src/testing/testing.go:1742 +0x668
r0 0x16ee9adf8
r1 0x10105f820
r2 0x16ee9ada0
r3 0x14000002540
r4 0x0
r5 0x27100
r6 0x989680
r7 0x2
r8 0x14000054008
r9 0x1f8ed26e0
r10 0x11
r11 0x0
r12 0x0
r13 0x16ee9ad90
r14 0x0
r15 0x0
r16 0x1a01e9474
r17 0x1fa08d928
r18 0x0
r19 0x16ee9adf8
r20 0x7d
r21 0x3
r22 0x0
r23 0x0
r24 0x0
r25 0x0
r26 0x10121cf48
r27 0x40
r28 0x14000002540
r29 0x16ee9ad48
lr 0x10105f834
sp 0x16ee9ad50
pc 0x1011b5b54
fault 0x1011b5b54
FAIL command-line-arguments 0.225s
FAIL
Expected behavior
all test cases pass without any error
Screenshots

Mockey version:
v1.2.12
Environment:
__
arm64
darwin21.0
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/xxx/Library/Caches/go-build'
GOENV='/Users/xxx/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/usr/local/lib/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/usr/local/lib/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.22.5/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.5/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/xxx/tmp/1726123276/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/4m/sn7j4g7j1t1f5sl00hnprt1w0000gn/T/go-build2760818345=/tmp/go-build -gno-record-gcc-switches -fno-common'
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working