Skip to content

runtime/debug.SetCrashOutput + GOGC=off + GOMEMLIMIT can lead to OOM kills #73490

Closed
@felixge

Description

@felixge

We recently noticed some OOM kills, and after a fun debugging adventure involving core dumps, we concluded that the issue was caused by our usage of the SetCrashOutput API which mirrors the example from the documentation.

In our case the parent process is subject to a GOMEMLIMIT env variable, and the child process inherited it. This in combination with some init functions that were spawning background goroutine activity caused the child process to grow its heap without the GC kicking in due to the high memory limit inherited from the parent process. Eventually this lead to the child+parent exceeding the memory limit of the container, resulting in an OOM kill.

Suggestion: Let's update the docs to either strip the memory limit env var or avoid passing any environment variables from the parent process (remove the os.Environ()). I can send a patch if there is consensus behind either of those two approaches.

cc @mknyszek

Edit: The parent process was also setting GOGC=off. That's what actually caused the OOM.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions