You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "Ethan-Xingyue (via GitHub)" <gi...@apache.org> on 2026/09/14 08:25:11 UTC

[I] [BUG] [CI][Test] TestGrpcGlobalTransactionBegin crashes under -race on modern Go because gomonkey method patches are unstable; CI is pinned to Go 1.20.14 [incubator-seata-go]

Ethan-Xingyue opened a new issue, #1175:
URL: https://github.com/apache/incubator-seata-go/issues/1175

   ## 🚀 Go Version
   
   go1.24.3 darwin/arm64 (CI: 1.20.14)
   
   ## 📦 Seata-go Version
   
   master, commit 3bf73586af81db1bd428982c93d82000d80cb1c8 (fetched 2026-09-02)
   
   ## 💾 Operating System
   
   macOS
   
   ## 📝 Bug Description
   
   `.github/workflows/unit-test.yml` runs `go test -v ./... -race ...` on Go 1.20.14 only, via `actions/setup-go@v3`:
   
   https://github.com/apache/incubator-seata-go/blob/3bf73586af81db1bd428982c93d82000d80cb1c8/.github/workflows/unit-test.yml#L36-L66
   
   Running the same race test on a current toolchain crashes. `TestGrpcGlobalTransactionBegin` patches methods of the `GetGrpcRemotingClient()` singleton with `gomonkey.ApplyMethod` (https://github.com/apache/incubator-seata-go/blob/3bf73586af81db1bd428982c93d82000d80cb1c8/pkg/tm/transaction/grpc/grpc_global_transaction_test.go#L122-L133):
   
   - On go1.24.3 darwin/arm64 with `-race`, the first three cases log their expected errors and the test process then dies with `unexpected fault address ... fatal error: fault [signal SIGBUS]` at `grpc_global_transaction_test.go:133`.
   - On go1.25.5 the failure was observed as a nil pointer dereference inside the real `channelManager` after a patch silently stopped applying (reported by a separate audit run, not re-verified here).
   - Without `-race` the same test passes on go1.24.3 (`ok seata.apache.org/seata-go/v2/pkg/tm/transaction/grpc 1.440s`).
   
   Root cause: the tests rely on rewriting machine code of methods at runtime. Race instrumentation and newer compilers change inlining and code layout, so the patches either crash or silently stop applying and the test falls through to the real, uninitialised gRPC remoting/channel manager. `-gcflags=all=-l` hides the problem but cannot be a permanent CI setting.
   
   This blocks moving CI off Go 1.20 (see #1154) and makes the test seam untrustworthy. Related: #479.
   
   Suggested priority: P1 (blocks the toolchain upgrade; not a proven production race).
   
   ## 🔄 Steps to Reproduce
   
   ```bash
   git clone https://github.com/apache/incubator-seata-go.git
   cd incubator-seata-go
   git checkout 3bf73586af81db1bd428982c93d82000d80cb1c8
   go version
   go test -race -run '^TestGrpcGlobalTransactionBegin$' -count=1 ./pkg/tm/transaction/grpc
   go test -run '^TestGrpcGlobalTransactionBegin$' -count=1 ./pkg/tm/transaction/grpc   # passes
   ```
   
   ## ✅ Expected Behavior
   
   The test passes reliably on current stable and oldstable Go, with and without `-race`, and does not depend on whether runtime code patching survives compiler changes.
   
   ## ❌ Actual Behavior
   
   go1.24.3 darwin/arm64, `-race` (excerpt; the three ERROR log lines from the first cases are omitted):
   
   ```text
   unexpected fault address 0xc00004cf60
   fatal error: fault
   [signal SIGBUS: bus error code=0x1 addr=0xc00004cf60 pc=0xc00004cf60]
   ...
   goroutine 5 gp=0xc0003c3340 m=0 mp=0x1016a1cc0 [running]:
   runtime.throw({0x100d56c65?, 0x100c9766c?})
   	/opt/homebrew/Cellar/go/1.24.3/libexec/src/runtime/panic.go:1101 +0x38 fp=0xc0003d94d0 sp=0xc0003d94a0 pc=0x10036f268
   runtime.sigpanic()
   	/opt/homebrew/Cellar/go/1.24.3/libexec/src/runtime/signal_unix.go:922 +0x170 fp=0xc0003d9530 sp=0xc0003d94d0 pc=0x100371770
   seata.apache.org/seata-go/v2/pkg/tm/transaction/grpc_test.TestGrpcGlobalTransactionBegin(0xc0003c36c0)
   	<checkout>/pkg/tm/transaction/grpc/grpc_global_transaction_test.go:133 +0x6b0 fp=0xc0003d9ec0 sp=0xc0003d9540 pc=0x100c986b0
   testing.tRunner(0xc0003c36c0, 0x1010850c8)
   ...
   FAIL	seata.apache.org/seata-go/v2/pkg/tm/transaction/grpc	1.443s
   FAIL
   ```
   
   ## 💡 Possible Solution
   
   - Replace `gomonkey.ApplyMethod` on the remoting singleton with an injectable `RemotingClient` interface or fake; use `-gcflags=all=-l` only as a temporary bridge while migrating.
   - Upgrade the workflow to a maintained `actions/setup-go` and a stable/oldstable Go matrix.
   - Migrate this test first, then converge the remaining monkey patches package by package; do not bundle large production refactors into the same PR.
   
   Acceptance criteria:
   
   - [ ] The command above passes 20 consecutive runs on stable and oldstable Go, with and without `-race`.
   - [ ] The test does not need `-gcflags=all=-l` and does not touch the real network or channel singleton.
   - [ ] CI action and Go matrix are upgraded; the matrix matches the minimum Go version stated in the README.
   - [ ] Any remaining full-suite race failures are classified as real race / test seam / business bug, each with an owner or a separate issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [I] [BUG] [CI][Test] TestGrpcGlobalTransactionBegin crashes under -race on modern Go because gomonkey method patches are unstable; CI is pinned to Go 1.20.14 [incubator-seata-go]

Posted by "wangchenxuya (via GitHub)" <gi...@apache.org>.
wangchenxuya commented on issue #1175:
URL: https://github.com/apache/incubator-seata-go/issues/1175#issuecomment-5661267212

   I'd like to take this
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org