# Stacktrace Split Capture/Resolve, Bounded Cache, Safe Snippets, and Crash Marker Task ID: M-STACKTRACE-01..04 Phase: P2 Status: APPROVED Contracts: C-01, C-02, C-03, C-04, C-05 ## 1. Context and baseline `Void::Stacktrace` currently couples raw capture with demangling, source snippet file reads, and `Void::Log` diagnostics, has no explicit `Capabilities` query or async-signal-safe fatal marker helper, and has no standalone test directory under `tests/standalone/Stacktrace/`. ## 2. Deliverables - `src/Stacktrace/module.cmake`: add `Time` (`INTERNAL_DEPS Functional Time LogState`) - `include/Void/Stacktrace/Stacktrace.hpp` & `src/Stacktrace/Stacktrace.cpp`: - Legacy `StackFrame`, `capture_stacktrace`, `read_source_snippet`, `format_stacktrace`, `print_stacktrace` preserved. - `kStacktraceErrorDomain = 13` `StacktraceErrorCode` + `make_stacktrace_error`. - `Capabilities` (`raw_capture`, `symbols`, `line_info`, `async_signal_safe = false`, `backend_name`) + `capabilities() noexcept`. - `CaptureOptions`, owned `RawFrame` (`address`, `module_offset`, `module_path`, `module_id`), `RawTrace`, `capture()` (validates `1 <= max_frames <= 256`, zero source IO, zero `Void::Log` calls). - `FrameResolveStatus`, `ResolvedFrame`, `ResolvedTrace`, `ResolveOptions`, `Resolver` (bounded `1024` entries / `4 MiB` cache keyed by `(module_id, module_offset)`, `invalidate_module`, `clear_cache`), `read_source_snippet_checked` (allowed roots, symlink-escape rejection, overflow-safe line math, byte limits), `format_resolved_trace`, `write_fatal_signal_marker(int fd, int sig) noexcept`. - `tests/standalone/Stacktrace/Stacktrace.cpp` ## 3. Edge cases - Pre-cancelled `stop_token` and expired `ManualClock` deadline return `incomplete == true` while preserving captured raw frames. - Path traversal (`..`) and symlinks escaping `allowed_source_roots` fail with `unsafe_path`; `INT_MAX` line arithmetic never overflows. ## 4. Verification commands ```sh dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w5-stacktrace -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVOID_ENABLED_MODULES="Stacktrace;Testing" -DVOID_WARNINGS_AS_ERRORS=ON -DFETCHCONTENT_SOURCE_DIR_BOOST=/home/faumaray/Projects/VoidLibrary/build/_deps/boost-src && cmake --build /tmp/void-w5-stacktrace && /tmp/void-w5-stacktrace/tests/VoidTests --filter "Stacktrace*"' ```