Skip to content

Commit

Permalink
Merge pull request tmm1#132 from imjching-shopify/make-empty-hash-global
Browse files Browse the repository at this point in the history
Mark the metadata object before the GC is invoked to prevent it from being garbage collected
  • Loading branch information
tenderlove authored Dec 17, 2019
2 parents a701706 + 7eb0658 commit c1cd15f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ext/stackprof/stackprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ stackprof_results(int argc, VALUE *argv, VALUE self)
rb_hash_aset(results, sym_missed_samples, SIZET2NUM(_stackprof.overall_signals - _stackprof.overall_samples));
rb_hash_aset(results, sym_metadata, _stackprof.metadata);

_stackprof.metadata = Qnil;

frames = rb_hash_new();
rb_hash_aset(results, sym_frames, frames);
st_foreach(_stackprof.frames, frame_i, (st_data_t)frames);
Expand Down Expand Up @@ -653,6 +655,9 @@ frame_mark_i(st_data_t key, st_data_t val, st_data_t arg)
static void
stackprof_gc_mark(void *data)
{
if (RTEST(_stackprof.metadata))
rb_gc_mark(_stackprof.metadata);

if (RTEST(_stackprof.out))
rb_gc_mark(_stackprof.out);

Expand Down

0 comments on commit c1cd15f

Please sign in to comment.