Skip to content

Deterministic or guaranteed recursion depth (stack size) #9627

@roberth

Description

@roberth

Is your feature request related to a problem? Please describe.

Currently we use arbitrary stack sizes, as "suggested" by the operating system.
This leads expressions with deep recursion to crash on some machines, but not others.

Describe the solution you'd like

Get a consistent logical stack size, regardless of operating system or cpu architecture.

Larger, or even "infinite" stack sizes can be implemented with a segmented stack.
Coroutines can be used to implement that, but I don't know if we should commit to coroutines, as their interaction with the GC still isn't quite solved. Currently they're only really used in the evaluator during source filtering, which why we can get away with workarounds, such as:

Describe alternatives you've considered

Alternatively, we may determine a stack size that is "large enough", configure it to be that large, keep count in the evaluator, and error out, as proposed in

This also has a bad interaction with coroutines, which is having to allocate a significantly larger stack, which makes adding many sources more expensive.

Additional context

Priorities

Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugerror-messagesConfusing messages and better diagnosticsfeatureFeature request or proposallanguageThe Nix expression language; parser, interpreter, primops, evaluation, etc

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions