-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: unexpected return pc for github.com/pact-foundation/pact-go #67670
Comments
Hmm, that looks like corruption found while processing defers, followed by an inability to unwind correctly. I can reproduce, although it would be nice to have repro instructions that didn't involve It might be good to audit your use of unsafe and cgo and see if you can find any cases where memory corruption could occur. |
Bisect points to https://go-review.googlesource.com/c/go/+/516198 as the cause. That CL only changes the internal layout of defer records, which shouldn't be observable. |
Ok, some progress. My best guess is that Do the following patch to the runtime (I'm working on tip, but this should also work on 1.22):
Then do the following patch to
The panic added there in This prints the contents of the stack frame of This bug is very sensitive to the stack frame layout of I don't yet understand where the clobbering write is coming from. My best guess is the code for |
Update: gdb watchpoints save the day! A bit of fiddling and they showed who was writing to the slot in question. It's cgo's fault.
@ianlancetaylor Does any of this sound familiar? |
I think I see the problem.
But in
Note the different return type. If you make them both return Somehow with the different definitions, at the callsite the compiler is assuming a So I think this is a bug on pact-go's side. Possibly we should have cgo complain if it sees this inconsistency. It certainly would be helpful to get a compiler error instead of have to trace down this runtime failure. |
Closing as this isn't a Go bug. I opened #67699 to track getting better detection of conflicting declarations from cgo. |
Amazing troubleshooting @randall77 (from a Pact maintainer) We rely on a shared library built in rust, and consume in various languages. CGO has been a bit of a black-box to me and I struggle to work out where to start with diagnosing so this is really valuable. Thanks for taking the time to investigate and proposing a fix on pact-go's side. I'll look through your notes and create some easy to follow steps for our users of the lib to help attach to bug reports.
totally agree, thanks for raising that separate issue!
sorry about that, it requires sudo because it installs the shared library to a well known location for cgo linking without modifying LD_LIBRARY_PATH, but on linux and macos they are root protected. That is configurable though by the user, so we can provide steps that don't require sudo in future. |
Also another Pact maintainer here - echoing Yousaf's sentiments, I just wanted to thank you as well - this was an excellent experience and much appreciated 🙏 . |
Go version
go version go1.22.3 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Trying to run test with pact-go library.
Reproducable codes is here:
https://github.com/m15o/pact-go-on-golang1.22
Reproduced on github actions:
https://github.com/m15o/pact-go-on-golang1.22/actions/runs/9261497614
Since version v1.22.0 I get a runtime error when the
-race
option is present.This does not happen on darwin/arm64
What did you see happen?
command:
output:
What did you expect to see?
run test without runtime error
The text was updated successfully, but these errors were encountered: