mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 21:16:02 +01:00
Make EvalState::callDepth thread-local
This is needed to make it thread-safe.
This commit is contained in:
parent
e8314e69ab
commit
67769e6fc1
2 changed files with 13 additions and 9 deletions
|
|
@ -1533,6 +1533,8 @@ void ExprLambda::eval(EvalState & state, Env & env, Value & v)
|
|||
v.mkLambda(&env, this);
|
||||
}
|
||||
|
||||
thread_local size_t EvalState::callDepth = 0;
|
||||
|
||||
void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes, const PosIdx pos)
|
||||
{
|
||||
auto _level = addCallDepth(pos);
|
||||
|
|
|
|||
|
|
@ -52,15 +52,15 @@ namespace eval_cache {
|
|||
* Increments a count on construction and decrements on destruction.
|
||||
*/
|
||||
class CallDepth {
|
||||
size_t & count;
|
||||
size_t & count;
|
||||
|
||||
public:
|
||||
CallDepth(size_t & count) : count(count) {
|
||||
++count;
|
||||
}
|
||||
~CallDepth() {
|
||||
--count;
|
||||
}
|
||||
CallDepth(size_t & count) : count(count) {
|
||||
++count;
|
||||
}
|
||||
~CallDepth() {
|
||||
--count;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -710,9 +710,11 @@ private:
|
|||
std::shared_ptr<StaticEnv> & staticEnv);
|
||||
|
||||
/**
|
||||
* Current Nix call stack depth, used with `max-call-depth` setting to throw stack overflow hopefully before we run out of system stack.
|
||||
* Current Nix call stack depth, used with `max-call-depth`
|
||||
* setting to throw stack overflow hopefully before we run out of
|
||||
* system stack.
|
||||
*/
|
||||
size_t callDepth = 0;
|
||||
thread_local static size_t callDepth;
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue