about summary refs log tree commit diff
path: root/tvix/eval/Cargo.toml
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2022-11-23T03·42-0800
committerclbot <clbot@tvl.fyi>2022-11-26T19·41+0000
commit56c00df71036a3560a5f710f527fe7ece54eb665 (patch)
treeedef06641f680dff40cad4dd82147343d180653d /tvix/eval/Cargo.toml
parent4b09f015711230bcb51135e63e58dcfeb0da0510 (diff)
feat(tvix/eval): use backtrace-on-stack-overflow crate r/5340
The backtrace-on-stack-overflow create provides best-effort stack
traces when a stack overflow happens.  Since it's running on the
(usually tiny) signal alternate stack this isn't easy.

This is guarded by a new `backtrace_overflow` feature flag and never
enabled (even if that feature is selected) for release builds.  This
is strictly for debugging; there's crazy unsafe voodoo in there.

   https://lib.rs/crates/backtrace-on-stack-overflow

Example output:

```
Stack Overflow:
   0: backtrace_on_stack_overflow::handle_sigsegv
             at /home/amjoseph/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-on-stack-overflow-0.2.0/src/lib.rs:93:40
   1: <unknown>
   2: __rust_probestack
   3: tvix_eval::vm::VM::run_op
             at src/vm.rs:399
   4: tvix_eval::vm::VM::run
             at src/vm.rs:388:23
   5: tvix_eval::vm::VM::enter_frame
             at src/vm.rs:360:22
   6: tvix_eval::value::thunk::Thunk::force
             at src/value/thunk.rs:116:25
   7: tvix_eval::vm::VM::run_op
             at src/vm.rs:801:37
   8: tvix_eval::vm::VM::run
             at src/vm.rs:388:23
   9: tvix_eval::vm::VM::enter_frame
             at src/vm.rs:360:22
  10: tvix_eval::value::thunk::Thunk::force
             at src/value/thunk.rs:116:25
...
```

Signed-off-by: Adam Joseph <adam@westernsemico.com>
Change-Id: I1d8a2017f836be7bf91a2223e7adacb86fa1dbb2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7354
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/eval/Cargo.toml')
-rw-r--r--tvix/eval/Cargo.toml6
1 files changed, 5 insertions, 1 deletions
diff --git a/tvix/eval/Cargo.toml b/tvix/eval/Cargo.toml
index ce72745889..1d42b793d3 100644
--- a/tvix/eval/Cargo.toml
+++ b/tvix/eval/Cargo.toml
@@ -28,6 +28,7 @@ serde = "1.0"
 serde_json = "1.0"
 regex = "1.6.0"
 builtin-macros = { path = "./builtin-macros", package = "tvix-eval-builtin-macros" }
+backtrace-on-stack-overflow = { version = "0.2.0", optional = true }
 
 # rnix has not been released in a while (as of 2022-09-23), we will
 # use it from git.
@@ -43,7 +44,7 @@ itertools = "0.10.3"
 tempdir = "0.3.7"
 
 [features]
-default = [ "repl", "impure", "arbitrary", "nix_tests" ]
+default = [ "repl", "impure", "arbitrary", "nix_tests", "backtrace_overflow" ]
 
 # Enables running the Nix language test suite from the original C++
 # Nix implementation (at version 2.3) against Tvix.
@@ -58,6 +59,9 @@ impure = []
 # Enables Arbitrary impls for internal types (required to run tests)
 arbitrary = [ "proptest", "test-strategy" ]
 
+# For debugging use only; not appropriate for production use.
+backtrace_overflow = [ "backtrace-on-stack-overflow" ]
+
 [[bench]]
 name = "eval"
 harness = false