mirror of
https://github.com/NixOS/nix
synced 2025-06-25 02:21:16 +02:00
fix(libexpr/eval-inline): get rid of references to nullptr env
When diagnosing infinite recursion references to nullptr `Env` can be formed. This happens only with `ExprBlackHole` is evaluated, which always leads to `InfiniteRecursionError`. UBSAN log for one such case: ``` ../src/libexpr/eval-inline.hh:94:31: runtime error: reference binding to null pointer of type 'Env' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/libexpr/eval-inline.hh:94:31 in ```
This commit is contained in:
parent
32becc87fe
commit
1800853b2a
3 changed files with 11 additions and 3 deletions
|
@ -2052,9 +2052,12 @@ void ExprPos::eval(EvalState & state, Env & env, Value & v)
|
|||
state.mkPos(v, pos);
|
||||
}
|
||||
|
||||
|
||||
void ExprBlackHole::eval(EvalState & state, Env & env, Value & v)
|
||||
void ExprBlackHole::eval(EvalState & state, [[maybe_unused]] Env & env, Value & v)
|
||||
{
|
||||
throwInfiniteRecursionError(state, v);
|
||||
}
|
||||
|
||||
[[gnu::noinline]] [[noreturn]] void ExprBlackHole::throwInfiniteRecursionError(EvalState & state, Value &v) {
|
||||
state.error<InfiniteRecursionError>("infinite recursion encountered")
|
||||
.atPos(v.determinePos(noPos))
|
||||
.debugThrow();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue