about summary refs log tree commit diff
path: root/tvix/eval/src/tests/tvix_tests
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2022-10-10T23·37-0400
committergrfn <grfn@gws.fyi>2022-10-11T00·08+0000
commit4a058a9c00d772c22a4ddbe256e8a95c19bfaacb (patch)
tree3f492be8c7c989d1b074c443658762324841255f /tvix/eval/src/tests/tvix_tests
parent76e0c37b9eb9e2ddf6cedbbf0b5a1d2a603de0c4 (diff)
fix(tvix/eval): Pop frames even if running op fails r/5100
Previously, the VM assumed that if an error was returned from `run()`,
the evaluation was "finished" and the state of the VM didn't matter.
This used to be a reasonable assumption, but now that we've got
`tryEval` around we need to actually make sure that we clean up after
ourselves if we're about to return an error. Specifically, if the *last*
instruction in an evaluation frame returns an error, we previously
wouldn't pop that evaluation frame, which could cause all sorts of
bizarre errors based on what happened to be in the stack at the time.

This commit splits out a `run_op` method from `VM::run`, and uses that
to check the evaluation frame return condition even if the op we're
running is about to return an error, and pop the evaluation frame if
we're at the last instruction.

Change-Id: Ib40649d8915ee1571153cb71e3d76492542fc3d7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6940
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/eval/src/tests/tvix_tests')
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.exp2
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.nix1
2 files changed, 2 insertions, 1 deletions
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.exp
index 770a5b6db405..8b6ed7dbac6b 100644
--- a/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.exp
+++ b/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.exp
@@ -1 +1 @@
-{ w = { success = false; value = false; }; x = { success = true; value = "x"; }; y = { success = false; value = false; }; z = { success = false; value = false; }; }
+{ v = false; w = { success = false; value = false; }; x = { success = true; value = "x"; }; y = { success = false; value = false; }; z = { success = false; value = false; }; }
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.nix
index 8915032abd6f..e2357c798753 100644
--- a/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.nix
+++ b/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.nix
@@ -1,4 +1,5 @@
 {
+  v = (builtins.tryEval (toString <oink>)).value;
   w = builtins.tryEval <nope>;
   x = builtins.tryEval "x";
   y = builtins.tryEval (assert false; "y");