-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/link: panic: machorelocsect: size mismatch #66993
Comments
@luhring Thanks for raising! We've also faced the same issue and looked into it. It's even easier to reproduce it.
We tried Go 1.22.0, 1.22.1, and 1.22.2, but the same error occurred with all of them. However,
We were trying to create a small project to replicate this problem, but it was taking a while. |
Awesome, thanks for the added context! 🙌 |
I met the same error when building bytebase by running
|
In one of my projects, I was able to narrow down this error happening as soon as I use https://github.com/aws/aws-sdk-go-v2 in go 1.22+. My workarounds are to exclude the library and all its usages via build flag, or to run the program in a container, which is obviously in Linux VM. I also investigated for a while and thought maybe I have some old linked library somewhere. Thank you for creating this issue. |
@randall77 would you help take a look? Thanks! |
@cherrymui This looks like a linker issue. That failing check is off by 8. |
Thanks for reporting. The direct problem is |
Change https://go.dev/cl/586555 mentions this issue: |
Wish I could still send Kudos for your help. Thank you! |
Also curious why it happens to Darwin/arm64 only? |
Because on ARM64 the C linker has a section size limit, so we need to split text sections. There is no such limit on AMD64. As for other OSes, the ELF linking is just different from Mach-O linking. |
Hi @cherrymui, we also found the regression in 1.22 that go build with -gcflags="all=-N -l" will fail with the following error. Hope you could shed some light on it as well. Thanks! /Users/danny/tools/go/pkg/tool/darwin_arm64/link: running clang failed: exit status 1 |
@d-bytebase Based on the error message the problem you're reporting is not related to the one described here. Would you please open another issue? Thanks. Be sure to include details instructions on how to reproduce. |
Thanks. I figured it out as it has nothing to do with golang but clang, simply put macos/arm64 is too bad. Golang's linker improvement is exactly solving this kinds of issue, and I found a way out. |
@gopherbot please backport this to Go 1.22. This causes build failures on darwin/arm64. |
Backport issue(s) opened: #67527 (for 1.22). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Change https://go.dev/cl/586081 mentions this issue: |
… symbol table in dynlink mode In dynamic linking mode (e.g. when using plugins) on darwin, the marker symbols runtime.text and runtime.etext are added to Textp in an early stage, so when adding symbols to the symbol table we don't need to explicitly add them. However, when splitting text sections, the runtime.text.N marker symbols for the addtional sections are not added to Textp. So we do need to add them explicitly to the symbol table. Updates #66993. Fixes #67527. Change-Id: Ic718d03cd71fc0bfb931cff82640b1f4c53b89be Reviewed-on: https://go-review.googlesource.com/c/go/+/586555 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com> (cherry picked from commit 9a9dd72) Reviewed-on: https://go-review.googlesource.com/c/go/+/586081
Go version
go version go1.22.2 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
Using GoLand, which I understand to use delve under the hood (see GoLand ticket where someone else is hitting this same issue), I attempted to start a debug session for the Trivy project: https://github.com/aquasecurity/trivy, running the program at
./cmd/trivy
.I'm able to reproduce this without GoLand, too, via:
I'm running on macOS 14.4.1, on an M1 processor.
cc: @knqyf263 in case this interests you!
What did you see happen?
(Note: I also had to temporarily adjust Trivy's
go.mod
to usetoolchain go1.22.2
so it matched my installed toolchain.)What did you expect to see?
I expected to be able to start a debugging session successfully, via either dlv or GoLand.
(I can't reproduce this issue using
go1.21.9
, FWIW.)The text was updated successfully, but these errors were encountered: