bytedance / mockey

a simple and easy-to-use golang mock library
Apache License 2.0
556 stars 22 forks source link

WriteSTW: SIGSEGV: segmentation violation code=0x2 #27

Closed felix021 closed 8 months ago

felix021 commented 1 year ago

Describe the bug

A test with mockey triggered an SIGSEGV error:

https://github.com/cloudwego/kitex/actions/runs/5398421069/jobs/9804653679?pr=1006

Do notice that the value of target changed in before WriteSTW calling write.

fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x2 addr=0x1c1000 pc=0xab720]

goroutine 157 [running]: runtime.throw({0x8944cd?, 0x71e4d4?}) /opt/hostedtoolcache/go/1.19.10/arm64/src/runtime/panic.go:1047 +0x40 fp=0xc00062fbb0 sp=0xc00062fb80 pc=0x753d0 runtime.sigpanic() /opt/hostedtoolcache/go/1.19.10/arm64/src/runtime/signal_unix.go:823 +0x1e4 fp=0xc00062fbe0 sp=0xc00062fbb0 pc=0x8e3c4 runtime.memmove() /opt/hostedtoolcache/go/1.19.10/arm64/src/runtime/memmove_arm64.s:48 +0x30 fp=0xc00062fbf0 sp=0xc00062fbf0 pc=0xab720 runtime.memmove(0x1c0ff0, 0xc00034a640, 0x18)

:1 +0x1c fp=0xc00062fc20 sp=0xc00062fbf0 pc=0xad3ec github.com/bytedance/mockey/internal/monkey/mem.write(0x1c0ff0, 0xc00034a640, 0x18, 0x1c0000, 0x1000, 0x5) /root/go/pkg/mod/github.com/bytedance/mockey@v1.2.0/internal/monkey/mem/write_linux_arm64.s:46 +0x104c fp=0xc00062fc50 sp=0xc00062fc20 pc=0x72df0c github.com/bytedance/mockey/internal/monkey/mem.Write(**0x1c0ff0**, {0xc00034a640, 0x18, 0x20}) /root/go/pkg/mod/github.com/bytedance/mockey@v1.2.0/internal/monkey/mem/write_linux.go:32 +0x178 fp=0xc00062fd20 sp=0xc00062fc50 pc=0x72ce18 github.com/bytedance/mockey/internal/monkey/mem.WriteWithSTW(**0x895d8b?**, {0xc00034a640, 0x18, 0x20}) /root/go/pkg/mod/github.com/bytedance/mockey@v1.2.0/internal/monkey/mem/write.go:29 +0x68 fp=0xc00062fdd0 sp=0xc00062fd20 pc=0x72cbe8 github.com/bytedance/mockey/internal/monkey.PatchValue({0x7b89c0?, 0x8ba0e8?, 0x1?}, {0x7b89c0?, 0xc000720330?, 0x12db7c?}, {0xc0005e27c0?, 0xc0004da1b0?, 0xc0006300a8?}, 0xac?) /root/go/pkg/mod/github.com/bytedance/mockey@v1.2.0/internal/monkey/patch.go:71 +0x780 fp=0xc00062fff0 sp=0xc00062fdd0 pc=0x72f830 github.com/bytedance/mockey.(*Mocker).Patch(0xc0005f3680) /root/go/pkg/mod/github.com/bytedance/mockey@v1.2.0/mock.go:243 +0x288 fp=0xc000630210 sp=0xc00062fff0 pc=0x732c58 github.com/bytedance/mockey.(*MockBuilder).Build(0xc0005e1260) /root/go/pkg/mod/github.com/bytedance/mockey@v1.2.0/mock.go:156 +0x224 fp=0xc000630340 sp=0xc000630210 pc=0x731914 github.com/cloudwego/kitex/pkg/generic.TestFromHTTPPbRequest.func1() /data00/runner/cloudwego-hl-arm-runner-01/kitex/kitex/pkg/generic/httppbthrift_codec_test.go:35 +0x1b4 fp=0xc0006303f0 sp=0xc000630340 pc=0x7[42](https://github.com/cloudwego/kitex/actions/runs/5398421069/jobs/9804653679?pr=1006#step:4:43)694

To Reproduce

With go1.19 arm64

  1. git clone github.com/cloudwego/kitex
  2. git checkout 6df72dc5a02659b6bdacd148f22d26863b311bd5
  3. go test github.com/cloudwego/kitex/pkg/generic

The error should occur when executing TestFromHTTPPbRequest

Expected behavior

There should be no error.

Screenshots

-

Mockey version:

v1.2.0

Environment:

The output of go env.

Additional context

Add any other context about the problem here.

ycydsxy commented 1 year ago

looks like runtime/memmove_arm64.s is in the same page, is this an occasional problem? @felix021

felix021 commented 1 year ago

looks like runtime/memmove_arm64.s is in the same page, is this an occasional problem? @felix021

No, every time we run the CI workflow (arm64 + go1.19), it fails at this test TestFromHTTPPbRequest, like this one: https://github.com/cloudwego/kitex/actions/runs/5442978689/jobs/9898909500?pr=1012