Better module backtraces for panics and whatnot#577
Better module backtraces for panics and whatnot#577coolreader18 wants to merge 5 commits intomasterfrom
Conversation
6581905 to
57888e9
Compare
|
I'd prefer we used something like color-eyre for formatting which already handles panics instead of rolling something custom we'd have to maintain. |
|
I just want to double check if the parsing and color formatting is happening in module code or not. |
kulakowski
left a comment
There was a problem hiding this comment.
Also, what's up with the smoketest
|
@RReverser does color-eyre panic stuff work in wasm? From what I can tell it doesn't expose the standalone backtrace formatting functionality, and even if it did it only supports the actual native |
|
@coolreader18 Does Wasmtime attaching symbols not help with backtrace? If it helps with gdb/lldb, there should be a way to make Rust backtraces use the same symbol resolution so that all these backtrace formatters/tools "just work". Another reason I'd really prefer not to do this on module side is that it further diverges support between module languages. With AOT we'll be able to get symbol names for C# functions in Wasm too, which will work correctly work with wasm2wat or debuggers, but still won't provide readable backtraces with this approach because it's doing something Rust-specific only in Rust modules. Ideally Wasm modules should be as opaque to the host as possible, and treated the same regardless of the language they were compiled in, especially if we add more langs down the line, otherwise we'll end up manually replicating same functionality for each language individually. |
|
No, wasm has no mechanism to access the call stack or the DWARF section. |
Wasm doesn't, but the native stack walker in
The changes in |
57888e9 to
0396a20
Compare
|
Bringin this one back, I guess. @RReverser you're correct that these changes are rust-specific, but the bindings crate changes are rust-specific because the bindings crate is rust-specific. If csharp has similar frames to |
|
Yeah I can't say I care much anymore, go ahead. |
0396a20 to
04b3961
Compare
04b3961 to
6e5367f
Compare
|
|
||
| [profile.release] | ||
| debug = 1 # include some location information for backtraces | ||
|
|
There was a problem hiding this comment.
Shouldn't we do this in all templates? And or make sure that cargo init has it? I assume if you don't do this, you get the same backtrace as before (or similar)?
|
|
||
| // based on fmt::Display impl for wasmtime::WasmBacktrace | ||
| // modified to print in color and to skip irrelevant frames | ||
| fn fmt_backtrace<W: WriteColor>(out: &mut W, trace: &[BacktraceFrame<'_>]) -> anyhow::Result<()> { |
There was a problem hiding this comment.
Why do we have this custom thing? Out of curiosity, if this changes the log format, will the website be impacted?
cloutiertyler
left a comment
There was a problem hiding this comment.
It's a little odd with the magic words, but I dunno, seems fine given that it's backwards compatible. We should follow up with C# and C++ as well.
Mirror the backtrace improvements from PR #577 (Rust/TS) to the C# and C++ module bindings so that stack traces captured by the host show actual reducer/procedure/view function names instead of anonymous wrappers. C# changes: - Add [MethodImpl(NoInlining)] to all generated Invoke() methods in reducer, procedure, and view dispatcher classes. This prevents the JIT/AOT from inlining these frames away, ensuring they appear as named WASM functions in wasmtime-captured backtraces. - Add Log.Error() in the reducer error handler for consistency with procedures and views, which already log full exceptions. C++ changes: - Add __attribute__((noinline)) to user function definitions in all macro variants: SPACETIMEDB_REDUCER, SPACETIMEDB_REDUCER_NAMED, SPACETIMEDB_INIT, SPACETIMEDB_CLIENT_CONNECTED, SPACETIMEDB_CLIENT_DISCONNECTED, SPACETIMEDB_VIEW, SPACETIMEDB_VIEW_NAMED, SPACETIMEDB_PROCEDURE, and SPACETIMEDB_PROCEDURE_NAMED. This ensures the actual user function name appears as a distinct frame in WASM backtraces rather than being optimized into the surrounding lambda wrappers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Mirror the backtrace improvements from PR #577 (Rust/TS) to the C# and C++ module bindings so that stack traces captured by the host show actual reducer/procedure/view function names instead of anonymous wrappers. C# changes: - Add [MethodImpl(NoInlining)] to all generated Invoke() methods in reducer, procedure, and view dispatcher classes. This prevents the JIT/AOT from inlining these frames away, ensuring they appear as named WASM functions in wasmtime-captured backtraces. - Add Log.Error() in the reducer error handler for consistency with procedures and views, which already log full exceptions. C++ changes: - Add __attribute__((noinline)) to user function definitions in all macro variants: SPACETIMEDB_REDUCER, SPACETIMEDB_REDUCER_NAMED, SPACETIMEDB_INIT, SPACETIMEDB_CLIENT_CONNECTED, SPACETIMEDB_CLIENT_DISCONNECTED, SPACETIMEDB_VIEW, SPACETIMEDB_VIEW_NAMED, SPACETIMEDB_PROCEDURE, and SPACETIMEDB_PROCEDURE_NAMED. This ensures the actual user function name appears as a distinct frame in WASM backtraces rather than being optimized into the surrounding lambda wrappers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Pushed This generalizes the short-backtrace fencepost name from the Rust-specific |
Description of Changes
Expected complexity level and risk
1 - it's pretty self-contained, and backwards-compatible with the existing logs data format