
Issue #20249 has been updated by osyoyu (Daisuke Aritomo).
I prefer to extend RUBY_CRASH_REPORT but is it possible to use the path name like foo=bar?
I don't think extending `RUBY_CRASH_REPORT` would be fully backwards-compatible. Nevertheless, use cases using paths including `=` could be rare enough to safely ignore. I have noticed `RUBY_CRASH_REPORT=key1=val,key2=val,...` requires two delimiters, one for splitting `items` and one for splitting config items. Some other ideas: ``` # Use space as delimiter RUBY_CRASH_REPORT_CONFIG='items=bt,cbt path=/path/to/output' ``` ``` # More shorthand for items RUBY_CRASH_REPORT_CONFIG='bt path=/path/to/output' # bt only RUBY_CRASH_REPORT_CONFIG='short +parallel path=/path/to/output' # bt, cbt, parallel RUBY_CRASH_REPORT_CONFIG='full -mm path=/path/to/output' # all but memory map ``` ---------------------------------------- Feature #20249: Introduce a backtrace-only mode for rb_bug() https://bugs.ruby-lang.org/issues/20249#change-111629 * Author: osyoyu (Daisuke Aritomo) * Status: Open ---------------------------------------- ## Background When a segfault or some unexpected situation occurs, `rb_bug()` is called and prints some few hundred to thousands of lines. The most helpful parts are (arguably) "Ruby level backtrace information" and "C-level backtrace information", but those parts are buried in the very lengthy report. In particular, the "Other runtime information" which contains the list of loaded features (scripts?) and the process memory map could be extremely long despite it does not come very useful, at least when developing C extensions. Even a minimal report from a simple script would consist of 250 lines and require 7 PgUps on my MacBook Air (13 inch) to reach the backtrace part, which contains all the information I need. ## Proposal My proposal is to default to a "minimal report" mode with a limited set of sections, perhaps only "Ruby level backtrace information" and "C level backtrace information" only When a full report is desired (i.e. for bug reports), the user could re-run the script with an special environment variable, such as `RUBY_FULL_CRASH_REPORT=1`. Rust implmements a similar pattern. It doesn't print the full backtrace on panics by default; instead, it guides the user to re-run the program with `RUST_BACKTRACE=1`. It might be hard to reproduce some crashes and segfaults, especially in long-running daemons. It might be nice to default to the "full" mode when stdout is not a tty, since daemons tend to run in non-tty environments. ## Appendix A typical crash report would look like this: ``` ../../example.rb: [BUG] ruby 3.4.0dev (2024-01-20T15:27:19Z master 366b14c0cd) [arm64-darwin23] -- Crash Report log information -------------------------------------------- (5 lines) -- Control frame information ----------------------------------------------- (~50 lines) -- Ruby level backtrace information ---------------------------------------- (depends on program; typically ~50 lines in Rails) -- C level backtrace information ------------------------------------------- (50+-ish lines, depends on program) -- Machine register context ------------------------------------------------ (~10 lines) -- Threading information --------------------------------------------------- (2 lines) -- Other runtime information ----------------------------------------------- * Loaded script (1 line) * Loaded features (depends on program; 800+ lines in Rails) * Process memory map (depends on environment; around 200 lines?) -- https://bugs.ruby-lang.org/