aboutsummaryrefslogtreecommitdiffstats
path: root/vm_dump.c
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2023-03-15 14:19:22 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2023-03-16 10:46:30 -0400
commit2f81bb793fd217374054ee78cb5cd595cfacf9fe (patch)
tree6c95425e8afecfc22cb08a65b6347bffc654ae5d /vm_dump.c
parente0cf80d666d4b5df3229f030a16d10d21323508e (diff)
downloadruby-2f81bb793fd217374054ee78cb5cd595cfacf9fe.tar.gz
Add thread and ractor counts to bug reports
This is useful for crash triaging. It also helps to hint extension developers about the misuse of `rb_thread_call_without_gvl()`. Example: $ ./miniruby -e 'Ractor.new{Ractor.receive}; Thread.new{sleep}; Process.kill:SEGV,Process.pid' <snip> -- Threading information --------------------------------------------------- Total ractor count: 2 Ruby thread count for this ractor: 2
Diffstat (limited to 'vm_dump.c')
-rw-r--r--vm_dump.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/vm_dump.c b/vm_dump.c
index 00e82078fd..fae34d72aa 100644
--- a/vm_dump.c
+++ b/vm_dump.c
@@ -1083,6 +1083,14 @@ rb_vm_bugreport(const void *ctx)
SDR();
rb_backtrace_print_as_bugreport();
fputs("\n", stderr);
+ // If we get here, hopefully things are intact enough that
+ // we can read these two numbers. It is an estimate because
+ // we are reading without synchronization.
+ fprintf(stderr, "-- Threading information "
+ "---------------------------------------------------\n");
+ fprintf(stderr, "Total ractor count: %u\n", vm->ractor.cnt);
+ fprintf(stderr, "Ruby thread count for this ractor: %u\n", rb_ec_ractor_ptr(ec)->threads.cnt);
+ fputs("\n", stderr);
}
rb_dump_machine_register(ctx);