Skip to content

proposal: runtime: make stack exhaustion recoverable #74577

@jupenur

Description

@jupenur

Proposal Details

Currently stack exhaustion in Go is a fatal error triggered by throw in newstack, i.e. non-recoverable. In many (most?) other languages, the equivalent condition is recoverable using standard error handling methods. Go's behavior is a source of many security issues. E.g. just in the standard library we have:

ID Package Description
Issue #10415 encoding/gob stack overflow
Issue #15879 path/filepath Glob with UNC path causes stack overflow
CVE-2022-1962 go/parser stack exhaustion in all Parse* functions
CVE-2022-24675 encoding/pem fix stack overflow in Decode
CVE-2022-24921 regexp stack exhaustion compiling deeply nested expressions
CVE-2022-28131 encoding/xml stack exhaustion in Decoder.Skip
CVE-2022-30630 io/fs stack exhaustion in Glob
CVE-2022-30631 compress/gzip stack exhaustion in Reader.Read
CVE-2022-30632 path/filepath stack exhaustion in Glob
CVE-2022-30633 encoding/xml stack exhaustion in Unmarshal
CVE-2022-30635 encoding/gob stack exhaustion in Decoder.Decode
CVE-2024-34155 go/parser stack exhaustion in all Parse* functions
CVE-2024-34156 encoding/gob stack exhaustion in Decoder.Decode
CVE-2024-34158 go/build/constraint stack exhaustion in Parse

In similarly complex third-party libraries these issues are likely even more common. Consumers of such libraries are unable to defend against crashes because the error is fatal.

The proposal is to make stack exhaustion a panic instead of a fatal error. Technically this would involve ensuring that enough stack is always available to handle panicking, which is currently not the case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions