Skip to content

Commit

Permalink
Fix SEGV caused by GC::Profiler.raw_data (#9122)
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro committed Dec 7, 2023
1 parent 5078aa8 commit 4f213ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gc.c
Expand Up @@ -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));
Expand Down
8 changes: 8 additions & 0 deletions test/ruby/test_gc.rb
Expand Up @@ -579,6 +579,14 @@ def test_profiler_clear
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
Expand Down

0 comments on commit 4f213ea

Please sign in to comment.