-
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: "fatal: morestack on g0" on amd64 after upgrade to Go 1.21 [1.21 backport] #63209
Comments
Change https://go.dev/cl/530480 mentions this issue: |
What's the status on this one? We were waiting for any bugs to shake out on tip, I believe? |
This needs an extra backport: https://go.dev/cl/537695, but has received enough soaking now. |
Change https://go.dev/cl/549495 mentions this issue: |
…on callback from C thread [This cherry-pick combines CL 527715, CL 527775, CL 527797, and CL 529216.] [This is a redo of CL 525455 with the test fixed on darwin by defining _XOPEN_SOURCE, and disabled with android, musl, and openbsd, which do not provide getcontext.] Since CL 495855, Ms are cached for C threads calling into Go, including the stack bounds of the system stack. Some C libraries (e.g., coroutine libraries) do manual stack management and may change stacks between calls to Go on the same thread. Changing the stack if there is more Go up the stack would be problematic. But if the calls are completely independent there is no particular reason for Go to care about the changing stack boundary. Thus, this CL allows the stack bounds to change in such cases. The primary downside here (besides additional complexity) is that normal systems that do not manipulate the stack may not notice unintentional stack corruption as quickly as before. Note that callbackUpdateSystemStack is written to be usable for the initial setup in needm as well as updating the stack in cgocallbackg. For #62440. For #62130. For #63209. Change-Id: I0fe0134f865932bbaff1fc0da377c35c013bd768 Reviewed-on: https://go-review.googlesource.com/c/go/+/527715 Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit 4f9fe6d) (cherry picked from commit e8ba057) (cherry picked from commit a843991) (cherry picked from commit d110d7c) Reviewed-on: https://go-review.googlesource.com/c/go/+/530480 Auto-Submit: Dmitri Shuralyov <dmitshur@google.com> TryBot-Bypass: Michael Pratt <mpratt@google.com>
After CL 527715, needm uses callbackUpdateSystemStack to set the stack bounds for g0 on an M from the extra M list. Since callbackUpdateSystemStack is also used for recursive cgocallback, it does nothing if the stack is already in bounds. Currently, the stack bounds in an extra M may contain stale bounds from a previous thread that used this M and then returned it to the extra list in dropm. Typically a new thread will not have an overlapping stack with an old thread, but because the old thread has exited there is a small chance that the C memory allocator will allocate the new thread's stack partially or fully overlapping with the old thread's stack. If this occurs, then callbackUpdateSystemStack will not update the stack bounds. If in addition, the overlap is partial such that SP on cgocallback is close to the recorded stack lower bound, then Go may quickly "overflow" the stack and crash with "morestack on g0". Fix this by clearing the stack bounds in dropm, which ensures that callbackUpdateSystemStack will unconditionally update the bounds in needm. For #62440. Fixes #63209. Change-Id: Ic9e2052c2090dd679ed716d1a23a86d66cbcada7 Reviewed-on: https://go-review.googlesource.com/c/go/+/537695 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> TryBot-Bypass: Michael Pratt <mpratt@google.com> (cherry picked from commit 1af424c) Reviewed-on: https://go-review.googlesource.com/c/go/+/549495 Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Closed by merging 7e34c43 to release-branch.go1.21. |
@prattmic requested issue #62440 to be considered for backport to the next 1.21 minor release.
The text was updated successfully, but these errors were encountered: