lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

  • Austin Clements's avatar
    runtime: don't start new threads from locked threads · 2595fe7f
    Austin Clements authored
    Applications that need to manipulate kernel thread state are currently
    on thin ice in Go: they can use LockOSThread to prevent other
    goroutines from running on the manipulated thread, but Go may clone
    this manipulated state into a new thread that's put into the runtime's
    thread pool along with other threads.
    
    Fix this by never starting a new thread from a locked thread or a
    thread that may have been started by C. Instead, the runtime starts a
    "template thread" with a known-good state. If it then needs to start a
    new thread but doesn't know that the current thread is in a good
    state, it forwards the thread creation to the template thread.
    
    Fixes #20676.
    
    Change-Id: I798137a56e04b7723d55997e9c5c085d1d910643
    Reviewed-on: https://go-review.googlesource.com/46033
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarKeith Randall <khr@golang.org>
    2595fe7f
runtime2.go 25.6 KB