Skip to content

Commit

Permalink
ShadowMemory should increment/decrement device handle
Browse files Browse the repository at this point in the history
ShadowMemory holds a reference to the appropriate device, but did not
retain/release it properly, resulting in use-after-frees in the asan
testing.
  • Loading branch information
RossBrunton committed Jan 15, 2025
1 parent 9e48f54 commit 782a3cf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/loader/layers/sanitizer/asan/asan_shadow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ namespace asan {

struct ShadowMemory {
ShadowMemory(ur_context_handle_t Context, ur_device_handle_t Device)
: Context(Context), Device(Device) {}
: Context(Context), Device(Device) {
urDeviceRetain(Device);
}

virtual ~ShadowMemory() {}
virtual ~ShadowMemory() { urDeviceRelease(Device); }

virtual ur_result_t Setup() = 0;

Expand Down

0 comments on commit 782a3cf

Please sign in to comment.