From 0c0ae50f024d48e9cc482dff164e5ba6bad4189d Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 2 Sep 2022 23:44:57 +0300 Subject: fix(tvix/eval): don't panic when printing a black hole 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 Tested-by: BuildkiteCI --- tvix/eval/src/value/thunk.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tvix') diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs index 59fe55cec9..e3f7846125 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]"), } } -- cgit 1.4.1