Skip to content

Commit d917e7d

Browse files
authored
[hip] Fixes a race in allocator_free_async. (#19541)
If we freed a buffer with hipFree and it was immediately re-used before the call to IREE_TRACE_FREE_NAMED, we could end up in a case where tracy would see the same buffer allocated twice (and subsequently crash) Signed-off-by: Andrew Woloszyn <[email protected]>
1 parent 9b8bba8 commit d917e7d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

runtime/src/iree/hal/drivers/hip/hip_allocator.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,14 +692,15 @@ iree_status_t iree_hal_hip_allocator_free_async(
692692
return iree_ok_status();
693693
}
694694

695-
IREE_RETURN_IF_ERROR(IREE_HIP_CALL_TO_STATUS(allocator->symbols,
696-
hipFree(device_ptr), "hipFree"));
697-
iree_hal_hip_buffer_set_allocation_empty(buffer);
698-
699695
IREE_TRACE_FREE_NAMED(IREE_HAL_HIP_ALLOCATOR_ID, (void*)device_ptr);
700696
IREE_STATISTICS(iree_hal_allocator_statistics_record_free(
701697
&allocator->statistics, iree_hal_buffer_memory_type(buffer),
702698
iree_hal_buffer_allocation_size(buffer)));
699+
700+
IREE_RETURN_IF_ERROR(IREE_HIP_CALL_TO_STATUS(allocator->symbols,
701+
hipFree(device_ptr), "hipFree"));
702+
iree_hal_hip_buffer_set_allocation_empty(buffer);
703+
703704
return iree_ok_status();
704705
}
705706

0 commit comments

Comments
 (0)