-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime, x/sys/unix: Connectx is broken on darwin/amd64 #71302
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
Comments
CC @golang/runtime |
Switching to the underlying syscall instead of libc suggests we're probably holding Darwin's libc wrong? Michael P notes maybe stack corruption from a mistake in how it's called? macOS requires us to call through libc for everything, so I'm not sure we should switch to making the underlying syscall directly. |
I think syscall9 is incorrect. The return values might not be plumbed back correctly. Try this patch:
|
I tested the patch provided by @randall77 and the result was still the same. It seems that the problem may not be caused by incorrect parsing of the return value. |
@randall77 I don't think there is a problem with What I wonder about instead is the assembler function As far as I know macOS is the same, though perhaps somebody could confirm that. If that is the case then we need to change Currently I believe that the only function that uses |
The use of |
Any chance we can get a fix for this? Thanks. |
Change https://go.dev/cl/665435 mentions this issue: |
Possible fixed listed above. Could someone try it? |
I tested https://go.googlesource.com/go/+/87973aae0be01e1be75ccfa60dc4aa1e539400c8 on golang1.24.2 and found that it still cannot be used normally. Moreover, it is different from the previous data error and panic. The current phenomenon seems that Connectx returns success but is not actually executed. |
I found a bug in my CL and pushed a fix. Could you try that? |
Thank you for the quick fix! I think this is it. In the tests @wwqgtxx ran, Still, let's wait until @wwqgtxx has the new results, just to be sure. |
Thanks for your help. After applying https://go.googlesource.com/go/+/a15345edabef8f40ae46e4e8117bd830ec0fb059, Connectx behaves normally and all tfo-go tests can pass on darwin amd64 platform. |
Ok, that's good. I'll get that CL in soon. I think the remaining question is, should we backport?
In opposition:
I'm leaning towards backporting. The fix is pretty simple and the unfixed behavior is very hard to debug and/or work around. @gopherbot please open backport issues |
Backport issue(s) opened: #73379 (for 1.24). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Should we also open a CL based on #71302 (comment), not for this issue, but like 57e3809 (CL 386719) did for #51247? |
I was incorrect on that referenced comment. Maybe we should fix syscall9 like we did in CL 386719, but I can't make it fail at the moment. This code
Compiles just fine with It would be good to be consistent between the different syscall functions, though. |
Yeah, perhaps this particular code path doesn't use as much stack space. It may be still good to be consistent. If we apply the patch as #71302 (comment) , we should also remove the cgo_unsafe_arg pragma. |
Change https://go.dev/cl/665695 mentions this issue: |
It uses less stack space this way. Similar to CL 386719 Update #71302 Change-Id: I585bde5f681a90a6900cbd326994ab8a122fd148 Reviewed-on: https://go-review.googlesource.com/c/go/+/665695 Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Go version
go version go1.23.5 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
@wwqgtxx reports that
x/sys/unix.Connectx
is broken on darwin/amd64. The call succeeds, but does not return the correct number of bytes sent, and may cause memory corruption (fatal error: stack not a power of 2
).They were able to work around the issue by making the following minimal change:
Connectx
was added by me in golang/sys@59665e5 (CL 606155). It does not have any issues on darwin/arm64. We spent hours on this and were not able to pinpoint the exact cause.What did you see happen?
Connectx
is broken on darwin/amd64.What did you expect to see?
Connectx
works on darwin/amd64.The text was updated successfully, but these errors were encountered: