summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2024-12-11 14:40:40 -0500
committerPeter Zhu <[email protected]>2024-12-12 14:07:56 -0500
commit79d90e73511dc9dfda7926802b624d6fec22fe12 (patch)
treef2003962a62beaa87e54ff6967e329c1ffe372e6 /gc.c
parent2da70aac258051d8a7eb89203e928a33727dbdf6 (diff)
Call rb_bug_without_die when ASAN error reported
This will give us the Ruby stack trace when an ASAN error is reported.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12309
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index 774f82bb5b..f4322417b6 100644
--- a/gc.c
+++ b/gc.c
@@ -936,6 +936,14 @@ ruby_modular_gc_init(void)
# define rb_gc_impl_copy_attributes rb_gc_functions.copy_attributes
#endif
+#ifdef RUBY_ASAN_ENABLED
+static void
+asan_death_callback(void)
+{
+ rb_bug_without_die("ASAN error");
+}
+#endif
+
static VALUE initial_stress = Qfalse;
void *
@@ -951,6 +959,10 @@ rb_objspace_alloc(void)
rb_gc_impl_objspace_init(objspace);
rb_gc_impl_stress_set(objspace, initial_stress);
+#ifdef RUBY_ASAN_ENABLED
+ __sanitizer_set_death_callback(asan_death_callback);
+#endif
+
return objspace;
}