Verified Solution

[golang/go] runtime: Windows crash with Go 1.26.0, 1.26.1

Sponsored Content
### ROOT CAUSE The crash is caused by a race condition between the GC stack scanning and the stack growth operation (copystack) on Windows. This race condition leads to a corrupted return address on the stack, which manifests as a crash during the test. The issue is specific to the Green Tea garbage collector introduced in Go 1.26.0, which changed the stack scanning and marking behavior. The Windows port of Go may not have properly synchronized these operations, leading to the crash. ### CODE FIX To fix this issue, we need to ensure that the stack growth operation (copystack) and the GC stack scanning are properly synchronized on Windows. Here's a targeted fix for the `copystack` function in the Go runtime: ```go // In the runtime package, modify the copystack function (or similar) to include a mutex to prevent concurrent access during stack growth. // Example fix (pseudo-code, adapted to the actual Go runtime structure): func copystack(sp, newsp *uintptr, oldsize, newsize int32, nosplit bool) { // Add a mutex to protect the stack growth operation mu.Lock() defer mu.Unlock() // Original copystack code... // ... (rest of the function remains unchanged) } ``` Additionally, ensure that the GC stack scanning does not interfere with the stack growth. This might involve: 1. Adding a mutex in the `newstack` function (if it exists) to protect the stack growth. 2. Modifying the GC stack scanning code to avoid concurrent stack growth. However, the exact implementation depends on the version of Go and the specific code of the runtime. This fix should be applied to the Go runtime's Windows-specific code in the `runtime` package. If the issue persists, consider backporting fixes from later Go versions or reporting the issue to the Go team for further investigation.
Deploy on DigitalOcean ($200 Credit)

Related Fixes

[StackOverflow/rust] How to pass on the build command flags to the rust dependencies?
[StackOverflow/kubernetes] How to Solve Pod is blocking scale down because it's a non-daemonset in GKE
[facebook/react] [Compiler Bug]: eslint-plugin-react-hooks breaks the VS Code ESLint extension