From 56c00df71036a3560a5f710f527fe7ece54eb665 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Tue, 22 Nov 2022 19:42:06 -0800 Subject: feat(tvix/eval): use backtrace-on-stack-overflow crate 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: 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 Change-Id: I1d8a2017f836be7bf91a2223e7adacb86fa1dbb2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7354 Tested-by: BuildkiteCI Reviewed-by: tazjin --- tvix/eval/Cargo.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tvix/eval/Cargo.toml') diff --git a/tvix/eval/Cargo.toml b/tvix/eval/Cargo.toml index ce72745889da..1d42b793d3c5 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 -- cgit 1.4.1