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/debug.WriteHeapDump() falls into infinite loop and "locks" program #9371

Closed
rfliam opened this issue Dec 17, 2014 · 3 comments
Closed

Comments

@rfliam
Copy link

rfliam commented Dec 17, 2014

Version: 1.3.3
OS: Fedora 21 X86_64
Sample Code For Reproduction: https://github.com/rfliam/heapdumptest

In the above sample code the WriteHeapDump function devolves into an infinite loop, that can only be exited by killing the program. The thread running WriteHeapDump runs at 100% cpu and the function never returns.

I believe this is the result of a reference loop in the goruntime. This reference loop seems to be made by interfaces which refer to each other in a loop.

@minux
Copy link
Member

minux commented Dec 17, 2014

Not reproducible on 1.4 or tip. Upgrade your Go version should fix the
problem.

@rfliam
Copy link
Author

rfliam commented Dec 18, 2014

The go 1.4 heapdump is binary incompatible with the go 1.3 heapdump and associated tools (also the documentation had bugs). No public tools currently exists to parse go 1.4 heap dumps. Changes to go 1.3 tools are non trivial, this is a followup from discussion on the mailing list regarding the matter.

While I would loved to see this fixed, it is also worth filing in case anyone else runs into it.

@randall77
Copy link
Contributor

I looked back at the 1.3.3 code. The bug happens with channels of size 0 where the size of the type is larger than the channel header (on 64 bit, 88 bytes). There's an underflow in the loop condition in heapdump.c:951 which makes the loop run ~2^64 iterations.

An easy workaround, and probably something you should do anyway, is pass large objects by reference.

This bug will not happen on 1.4 and beyond.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
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

4 participants