summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoutaro Matsumoto <[email protected]>2023-12-07 10:37:00 +0900
committerGitHub <[email protected]>2023-12-07 10:37:00 +0900
commit4f213ea1baa590c463c3554a6ff418d10dc291e0 (patch)
tree88b04188b5b3d7ee53dead4fef446d44a6180063
parent5078aa825c943f757f53a12264ab5e5c4cf1542e (diff)
Fix SEGV caused by `GC::Profiler.raw_data` (#9122)
-rw-r--r--gc.c2
-rw-r--r--test/ruby/test_gc.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index 993d81c2d6..8ab7a73862 100644
--- a/gc.c
+++ b/gc.c
@@ -13258,7 +13258,7 @@ gc_profile_record_get(VALUE _)
gc_profile_record *record = &objspace->profile.records[i];
prof = rb_hash_new();
- rb_hash_aset(prof, ID2SYM(rb_intern("GC_FLAGS")), gc_info_decode(0, rb_hash_new(), record->flags));
+ rb_hash_aset(prof, ID2SYM(rb_intern("GC_FLAGS")), gc_info_decode(objspace, rb_hash_new(), record->flags));
rb_hash_aset(prof, ID2SYM(rb_intern("GC_TIME")), DBL2NUM(record->gc_time));
rb_hash_aset(prof, ID2SYM(rb_intern("GC_INVOKE_TIME")), DBL2NUM(record->gc_invoke_time));
rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_USE_SIZE")), SIZET2NUM(record->heap_use_size));
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index b22f5b8a65..78bf9deb6b 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -579,6 +579,14 @@ class TestGc < Test::Unit::TestCase
RUBY
end
+ def test_profiler_raw_data
+ GC::Profiler.enable
+ GC.start
+ assert GC::Profiler.raw_data
+ ensure
+ GC::Profiler.disable
+ end
+
def test_profiler_total_time
GC::Profiler.enable
GC::Profiler.clear