-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Deterministic or guaranteed recursion depth (stack size) #9627
Copy link
Copy link
Open
Labels
bugerror-messagesConfusing messages and better diagnosticsConfusing messages and better diagnosticsfeatureFeature request or proposalFeature request or proposallanguageThe Nix expression language; parser, interpreter, primops, evaluation, etcThe Nix expression language; parser, interpreter, primops, evaluation, etc
Metadata
Metadata
Assignees
Labels
bugerror-messagesConfusing messages and better diagnosticsConfusing messages and better diagnosticsfeatureFeature request or proposalFeature request or proposallanguageThe Nix expression language; parser, interpreter, primops, evaluation, etcThe Nix expression language; parser, interpreter, primops, evaluation, etc
Fields
Give feedbackNo fields configured for issues without a type.
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.