Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PROF-10987] Add Ruby GC guard to heap profiler as a preventative measure #4187

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ext/datadog_profiling_native_extension/heap_recorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,10 @@ static int st_object_record_update(st_data_t key, st_data_t value, st_data_t ext
record->object_data.is_frozen = RB_OBJ_FROZEN(ref);
}

// Ensure that ref is kept on the stack so the Ruby garbage collector does not try to clean up the object before this
// point.
RB_GC_GUARD(ref);
ivoanjo marked this conversation as resolved.
Show resolved Hide resolved

recorder->stats_last_update.objects_alive++;
if (record->object_data.is_frozen) {
recorder->stats_last_update.objects_frozen++;
Expand Down
Loading