1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-28 13:11:00 +01:00

Merge pull request #14613 from roberth/deepSeq-stack-overflow

`deepSeq`, json: handle stack overflow, report list index
This commit is contained in:
Sergei Zimmerman 2025-11-22 17:49:32 +00:00 committed by GitHub
commit 8cdeab8f2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 194 additions and 1 deletions

View file

@ -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;
@ -2214,8 +2216,15 @@ void EvalState::forceValueDeep(Value & v)
}
else if (v.isList()) {
size_t index = 0;
for (auto v2 : v.listView())
recurse(*v2);
try {
recurse(*v2);
index++;
} catch (Error & e) {
state.addErrorTrace(e, "while evaluating list element at index %1%", index);
throw;
}
}
}(v);
}

View file

@ -16,6 +16,8 @@ json printValueAsJSON(
{
checkInterrupt();
auto _level = state.addCallDepth(pos);
if (strict)
state.forceValue(v, pos);