about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-09-02T20·44+0300
committertazjin <tazjin@tvl.su>2022-09-08T12·53+0000
commit0c0ae50f024d48e9cc482dff164e5ba6bad4189d (patch)
tree83e61434fab8cc38a6bde5aecd292562206f2737
parent2246a31e726762ea741a299f598c7878fa66dd83 (diff)
fix(tvix/eval): don't panic when printing a black hole r/4749
This could occur when the disassembler is enabled and tracing the
runtime while a thunk is being evaluated, as it would not be possible
for the *tracer* to borrow the thunk at this exact moment.

However, we know that if the borrowing fails here we are dealing with
a not-fully evaluated thunk (blackhole), which should just print the
internal representation.

Change-Id: I4bdb4f17818d55795368e3d28842048f488f0a91
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6416
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
-rw-r--r--tvix/eval/src/value/thunk.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs
index 59fe55cec945..e3f7846125f9 100644
--- a/tvix/eval/src/value/thunk.rs
+++ b/tvix/eval/src/value/thunk.rs
@@ -137,8 +137,12 @@ impl UpvalueCarrier for Thunk {
 
 impl Display for Thunk {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        match &*self.0.borrow() {
-            ThunkRepr::Evaluated(v) => v.fmt(f),
+        match self.0.try_borrow() {
+            Ok(repr) => match &*repr {
+                ThunkRepr::Evaluated(v) => v.fmt(f),
+                _ => f.write_str("internal[thunk]"),
+            },
+
             _ => f.write_str("internal[thunk]"),
         }
     }