mirror of
https://github.com/NixOS/nix.git
synced 2025-11-24 11:19:35 +01:00
builtins.deepSeq on deeply nested structures (e.g., a linked list with 100,000 elements) caused an uncontrolled OS-level stack overflow with no Nix stack trace. Fix by adding call depth tracking to forceValueDeep, integrating with Nix's existing max-call-depth mechanism. Now produces a controlled "stack overflow; max-call-depth exceeded" error with a proper stack trace. Closes: https://github.com/NixOS/nix/issues/7816
10 lines
367 B
Nix
10 lines
367 B
Nix
# Test that deepSeq on a deeply nested structure produces a controlled
|
|
# stack overflow error rather than a segfault.
|
|
|
|
let
|
|
long = builtins.genList (x: x) 100000;
|
|
reverseLinkedList = builtins.foldl' (tail: head: { inherit head tail; }) null long;
|
|
in
|
|
builtins.deepSeq reverseLinkedList (
|
|
throw "unexpected success; expected a controlled stack overflow instead"
|
|
)
|