• Austin Clements's avatar
    runtime: mark extra M's G as dead when not in use · 4e7067cd
    Austin Clements authored
    Currently the extra Ms created for cgo callbacks have a corresponding
    G that's kept in syscall state with only a call to goexit on its
    stack. This leads to confusing output from runtime.NumGoroutines and
    in tracebacks:
    
    goroutine 17 [syscall, locked to thread]:
    runtime.goexit()
    	.../src/runtime/asm_amd64.s:2197 +0x1
    
    Fix this by putting this goroutine into state _Gdead when it's not in
    use instead of _Gsyscall. To keep the goroutine counts correct, we
    also add one to sched.ngsys while the goroutine is in _Gdead. The
    effect of this is as if the goroutine simply doesn't exist when it's
    not in use.
    
    Fixes #16631.
    Fixes #16714.
    
    Change-Id: Ieae08a2febd4b3d00bef5c23fd6ca88fb2bb0087
    Reviewed-on: https://go-review.googlesource.com/45030
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    4e7067cd
Name
Last commit
Last update
..
windows Loading commit data...
aprof.go Loading commit data...
callback.go Loading commit data...
cgo.go Loading commit data...
crash.go Loading commit data...
deadlock.go Loading commit data...
dll_windows.go Loading commit data...
dropm.go Loading commit data...
dropm_stub.go Loading commit data...
exec.go Loading commit data...
main.go Loading commit data...
numgoroutine.go Loading commit data...
pprof.go Loading commit data...
raceprof.go Loading commit data...
racesig.go Loading commit data...
threadpanic.go Loading commit data...
threadpanic_unix.c Loading commit data...
threadpanic_windows.c Loading commit data...
threadpprof.go Loading commit data...
threadprof.go Loading commit data...
traceback.go Loading commit data...
tracebackctxt.go Loading commit data...
tracebackctxt_c.c Loading commit data...