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

libexpr: Clear PosTable contents in EvalState::resetFileCache

Otherwise PosTable grows indefinitely for each reload. Since
the total input size is limited to 4GB (uint32_t for byte offset PosIdx)
it can get exhausted pretty. This ensures that we don't waste memory
on reloads as well.
This commit is contained in:
Sergei Zimmerman 2025-11-09 22:09:18 +03:00
parent 479b6b73a9
commit a091a8100a
No known key found for this signature in database
2 changed files with 11 additions and 0 deletions

View file

@ -1113,6 +1113,7 @@ void EvalState::resetFileCache()
importResolutionCache->clear(); importResolutionCache->clear();
fileEvalCache->clear(); fileEvalCache->clear();
inputCache->clear(); inputCache->clear();
positions.clear();
} }
void EvalState::eval(Expr * e, Value & v) void EvalState::eval(Expr * e, Value & v)

View file

@ -111,6 +111,16 @@ public:
return o->origin; return o->origin;
return std::monostate{}; return std::monostate{};
} }
/**
* Remove all origins from the table.
*/
void clear()
{
auto lines = linesCache.lock();
lines->clear();
origins.clear();
}
}; };
} // namespace nix } // namespace nix