Commit 07f6f313 authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

runtime: say when a goroutine is locked to OS thread

Say when a goroutine is locked to OS thread in crash reports
and goroutine profiles.
It can be useful to understand what goroutines consume OS threads
(syscall and locked), e.g. if you forget to call UnlockOSThread
or leak locked goroutines.

R=golang-codereviews
CC=golang-codereviews, rsc
https://golang.org/cl/94170043
parent 9e04ff79
...@@ -297,10 +297,12 @@ runtime·goroutineheader(G *gp) ...@@ -297,10 +297,12 @@ runtime·goroutineheader(G *gp)
if((gp->status == Gwaiting || gp->status == Gsyscall) && gp->waitsince != 0) if((gp->status == Gwaiting || gp->status == Gsyscall) && gp->waitsince != 0)
waitfor = (runtime·nanotime() - gp->waitsince) / (60LL*1000*1000*1000); waitfor = (runtime·nanotime() - gp->waitsince) / (60LL*1000*1000*1000);
if(waitfor < 1) runtime·printf("goroutine %D [%s", gp->goid, status);
runtime·printf("goroutine %D [%s]:\n", gp->goid, status); if(waitfor >= 1)
else runtime·printf(", %D minutes", waitfor);
runtime·printf("goroutine %D [%s, %D minutes]:\n", gp->goid, status, waitfor); if(gp->lockedm != nil)
runtime·printf(", locked to thread");
runtime·printf("]:\n");
} }
void void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment