Conversation
087691b to
6dbc20c
Compare
roberth
approved these changes
Feb 18, 2026
Comment on lines
+236
to
+249
| template<typename Derived, typename Base> | ||
| class CloneableError : public Base | ||
| { | ||
| public: | ||
| using Base::Base; | ||
|
|
||
| /** | ||
| * Rethrow a copy of this exception. Useful when the exception can get | ||
| * modified when appending traces. | ||
| */ | ||
| [[noreturn]] void throwClone() const override | ||
| { | ||
| throw Derived(static_cast<const Derived &>(*this)); | ||
| } |
Member
There was a problem hiding this comment.
A necessary but mild annoyance that looks well executed to me.
xokdvium
commented
Feb 18, 2026
Comment on lines
+18
to
+19
| … forcing b | ||
|
|
Contributor
Author
There was a problem hiding this comment.
This is from the initial memoised stack trace. Pretty unavoidable and adds more context.
xokdvium
commented
Feb 18, 2026
6dbc20c to
abc4ae1
Compare
abc4ae1 to
4caa7fa
Compare
This is needed to make it possible to store exceptions in failed values with each new rethrow getting a fresh copy of the exception object.
In the multithreaded evaluator, it's possible for multiple threads to wait on the same thunk. If evaluation of the thunk results in an exception, the waiting threads shouldn't try to re-force the thunk. Instead, they should rethrow the same exception, without duplicating any work. Therefore, there is now a new value type `tFailed` that stores an std::exception_ptr. If evaluation of a thunk/app results in an exception, `forceValue()` overwrites the value with a `tFailed`. If `forceValue()` encounters a `tFailed`, it rethrows the exception. So you normally never need to check for failed values (since forcing them causes a rethrow). Co-authored-by: Robert Hensing <robert@roberthensing.nl>
This provides an explicit API for call-fail-retry-succeed evaluation flows, such as currently used in NixOps4. An alternative design would simply reset the `Value` to the original thunk instead of `tFailed` under the condition of catching a `RecoverableEvalError`. That is somewhat simpler, but I believe the presence of `tFailed` is beneficial for possible use in the repl; being able to show the error sooner, without re-evaluation. The hasPos method is required in order to avoid an include loop.
4caa7fa to
dd4b73a
Compare
Ericson2314
approved these changes
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Rebased version of #13930 that addresses concerns that @roberth voiced in #13930 (review) and in other review comments. My hope is to start working on getting async/concurrent evaluation upstream and this seems like a very natural way to propagate exceptions for suspendable work.
To address the trace mutation issue each error type now has an implementation of
ErrorBase::throwCloneaided by a CRTP mixinCloneableError. It's a bit of a churn, but I think this is the best way forward.Context
Closes #13930.
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.