From ed57a2682ca5ee4a16b47093b07106a2aa74bb4b Mon Sep 17 00:00:00 2001 From: Alexandre Fonseca Date: Thu, 14 Dec 2023 18:52:19 +0000 Subject: [PATCH] [PROF-8667] Fix heap recorder hash calculations after line type change --- ext/ddtrace_profiling_native_extension/heap_recorder.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/ddtrace_profiling_native_extension/heap_recorder.c b/ext/ddtrace_profiling_native_extension/heap_recorder.c index 272d9cf5e4a..2c1762d6330 100644 --- a/ext/ddtrace_profiling_native_extension/heap_recorder.c +++ b/ext/ddtrace_profiling_native_extension/heap_recorder.c @@ -560,7 +560,10 @@ st_index_t char_slice_hash(ddog_CharSlice char_slice, st_index_t seed) { st_index_t ddog_location_hash(ddog_prof_Location location, st_index_t seed) { st_index_t hash = char_slice_hash(location.function.name, seed); hash = char_slice_hash(location.function.filename, hash); - hash = st_hash(&location.line, sizeof(location.line), hash); + // Convert ddog_prof line type to the same type we use for our heap_frames to + // ensure we have compatible hashes + int32_t line_as_int32 = (int32_t) location.line; + hash = st_hash(&line_as_int32, sizeof(line_as_int32), hash); return hash; }