mirror of
https://github.com/NixOS/nix.git
synced 2025-11-27 20:51:00 +01:00
libexpr: fix stack overflow in deepSeq on deeply nested structures
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
This commit is contained in:
parent
152e7e48c1
commit
59a566db13
3 changed files with 42 additions and 0 deletions
|
|
@ -2188,6 +2188,8 @@ void EvalState::forceValueDeep(Value & v)
|
|||
std::set<const Value *> seen;
|
||||
|
||||
[&, &state(*this)](this const auto & recurse, Value & v) {
|
||||
auto _level = state.addCallDepth(v.determinePos(noPos));
|
||||
|
||||
if (!seen.insert(&v).second)
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue