Skip to content

Commit 782a3cf

Browse files
committed
ShadowMemory should increment/decrement device handle
ShadowMemory holds a reference to the appropriate device, but did not retain/release it properly, resulting in use-after-frees in the asan testing.
1 parent 9e48f54 commit 782a3cf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

source/loader/layers/sanitizer/asan/asan_shadow.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ namespace asan {
2222

2323
struct ShadowMemory {
2424
ShadowMemory(ur_context_handle_t Context, ur_device_handle_t Device)
25-
: Context(Context), Device(Device) {}
25+
: Context(Context), Device(Device) {
26+
urDeviceRetain(Device);
27+
}
2628

27-
virtual ~ShadowMemory() {}
29+
virtual ~ShadowMemory() { urDeviceRelease(Device); }
2830

2931
virtual ur_result_t Setup() = 0;
3032

0 commit comments

Comments
 (0)