Skip to content
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: code running on other threads does not show up in stack trace #4494

Closed
adonovan opened this issue Dec 5, 2012 · 12 comments
Closed

Comments

@adonovan
Copy link
Member

adonovan commented Dec 5, 2012

func main() {
  main()
}

This program hangs consuming 100% CPU and unbounded memory, as expected.

What is not expected is that delivering SIGQUIT to the program reveals nothing about
why.  Even running under gdb, interrupting, and issuing 'goroutine <id> bt' for
the two goroutines 1 and 2 shows only Go scheduler and memory allocation activity, with
rare exceptions.  (Presumably it's not tail-optimising the call and is allocating new
frames forever.)

(This is a minimized testcase from a larger program in which the number of calls in the
cycle was nontrivial and therefore much harder to guess at.)

% go version
go version devel +ab868a8f3128 Thu Nov 08 16:07:05 2012 -0500
% uname -a 
Linux adonovan.nyc.corp.google.com 2.6.38.8-gg987 #2 SMP Fri Sep 14 03:37:11 PDT 2012
x86_64 GNU/Linux
@rsc
Copy link
Contributor

rsc commented Dec 9, 2012

Comment 1:

Labels changed: added priority-later, removed priority-triage.

Owner changed to ---.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 2:

Labels changed: added size-l.

@huandu
Copy link
Contributor

huandu commented Jan 22, 2013

Comment 3:

Besides the stack trace issue, I hope to be able to set a limit on recursion depth in go
build flags. Once a goroutine reaches the max depth, it should panic with a runtime
error. With this build flag, it would be much easier to observe the issue.

@minux
Copy link
Member

minux commented Jan 22, 2013

Comment 4:

limit recursion depth is not very easy without performance hit.
however, we can limit maximum stack usage of a single goroutine.
(please file a new issue for the goroutine stack limit issue)

@adonovan
Copy link
Member Author

Comment 5:

I always thought it was a desirable feature of Go that recursion was not
limited by arbitrary choices of runtime stack size.

@minux
Copy link
Member

minux commented Jan 22, 2013

Comment 6:

yes, it is. thus we definitely shouldn't impose any stack limit by default.

@rsc
Copy link
Contributor

rsc commented Feb 15, 2013

Comment 7:

Smaller reproduction case, at least on a Mac:
package main
func main() {
  for{}
}
The problem is that the thread that gets the signal is not the thread executing - it's a
background thread sleeping - and when it dumps the goroutine stacks it has not access to
the other threads' register sets and cannot show the stacks for the goroutines they are
running.
To fix this we would have to pick a custom signal (SIGPROF maybe), send it to all the
other threads, and make the signal handler supply the goroutine stack. I'm not even sure
if OS X can target a signal to a specific thread.
See issue #4391, which will also require intraprocess signals. Yuck.

@rsc
Copy link
Contributor

rsc commented Mar 12, 2013

Comment 8:

Intraprocess signals are not going to happen before Go 1.1. There's no way we can get
them done and correct by then. Going to have to postpone.

Labels changed: added go1.2, removed go1.1.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 9:

Alan's program will show a correct stack trace in Go 1.2 because the function call will
poll for a preemption.
My program in comment #8 will not.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 10:

issue #5873 is the half that will be done in Go 1.2. The rest (for{}) will have to wait
at least until Go 1.3, if not longer.

Labels changed: added go1.3maybe, removed go1.2.

@rsc
Copy link
Contributor

rsc commented Aug 16, 2013

Comment 11:

This issue was closed by revision 757e0de.

Status changed to Fixed.

@robpike
Copy link
Contributor

robpike commented Aug 20, 2013

Comment 12:

Labels changed: removed go1.3maybe.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants