From cf523c89c06a0f480ec43a8adbc54d0ff453ebee Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Mon, 12 Feb 2018 16:42:49 +0100 Subject: [PATCH] Test the current thread's frame in heap snapshot Fixes a bug that can in the best case cause a SEGV (which is how I discovered it), and in the worst case lead to missing data in the report. --- src/profiler/heapsnapshot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/profiler/heapsnapshot.c b/src/profiler/heapsnapshot.c index cc68963b39..cf5a173f18 100644 --- a/src/profiler/heapsnapshot.c +++ b/src/profiler/heapsnapshot.c @@ -513,7 +513,8 @@ static void process_workitems(MVMThreadContext *tc, MVMHeapSnapshotState *ss) { case MVM_SNAPSHOT_COL_KIND_THREAD_ROOTS: { MVMThreadContext *thread_tc = (MVMThreadContext *)item.target; MVM_gc_root_add_tc_roots_to_worklist(thread_tc, NULL, ss); - if (thread_tc->cur_frame && !MVM_FRAME_IS_ON_CALLSTACK(thread_tc, tc->cur_frame)) + if (thread_tc->cur_frame && + !MVM_FRAME_IS_ON_CALLSTACK(thread_tc, thread_tc->cur_frame)) add_reference_const_cstr(tc, ss, "Current frame", get_frame_idx(tc, ss, thread_tc->cur_frame)); break;