Skip to content

Commit 5e2d619

Browse files
authored
[DeviceSanitizer] bugfix for buffer logger type error (#19009)
Buffer impl use `char*` pointer for `Ptr` and `HostPtr`, but that will confuse the logger and make it consider those as string and try to print them as string, which will result in SEGV.
1 parent 74c7854 commit 5e2d619

File tree

6 files changed

+9
-6
lines changed

6 files changed

+9
-6
lines changed

unified-runtime/source/loader/layers/sanitizer/asan/asan_buffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ ur_result_t MemBuffer::getHandle(ur_device_handle_t Device, char *&Handle) {
113113
UR_LOG_L(
114114
getContext()->logger, ERR,
115115
"Failed to copy {} bytes data from host pointer {} to buffer {}",
116-
Size, HostPtr, this);
116+
Size, (void *)HostPtr, this);
117117
return URes;
118118
}
119119
}
@@ -181,7 +181,7 @@ ur_result_t MemBuffer::free() {
181181
ur_result_t URes = getAsanInterceptor()->releaseMemory(Context, Ptr);
182182
if (URes != UR_RESULT_SUCCESS) {
183183
UR_LOG_L(getContext()->logger, ERR, "Failed to free buffer handle {}",
184-
Ptr);
184+
(void *)Ptr);
185185
return URes;
186186
}
187187
}

unified-runtime/source/loader/layers/sanitizer/asan/asan_buffer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct MemBuffer {
5959

6060
size_t Size;
6161

62+
// FIXME: we should use uint8_t* instead of char* for non-string data.
6263
char *HostPtr{};
6364

6465
struct SubBuffer_t {

unified-runtime/source/loader/layers/sanitizer/msan/msan_buffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ ur_result_t MemBuffer::getHandle(ur_device_handle_t Device, char *&Handle) {
153153
UR_LOG_L(
154154
getContext()->logger, ERR,
155155
"Failed to copy {} bytes data from host pointer {} to buffer {}",
156-
Size, HostPtr, this);
156+
Size, (void *)HostPtr, this);
157157
return URes;
158158
}
159159

@@ -227,7 +227,7 @@ ur_result_t MemBuffer::free() {
227227
ur_result_t URes = getContext()->urDdiTable.USM.pfnFree(Context, Ptr);
228228
if (URes != UR_RESULT_SUCCESS) {
229229
UR_LOG_L(getContext()->logger, ERR, "Failed to free buffer handle {}",
230-
Ptr);
230+
(void *)Ptr);
231231
return URes;
232232
}
233233
}

unified-runtime/source/loader/layers/sanitizer/msan/msan_buffer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct MemBuffer {
5959

6060
size_t Size;
6161

62+
// FIXME: we should use uint8_t* instead of char* for non-string data.
6263
char *HostPtr{};
6364

6465
struct SubBuffer_t {

unified-runtime/source/loader/layers/sanitizer/tsan/tsan_buffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ ur_result_t MemBuffer::getHandle(ur_device_handle_t Device, char *&Handle) {
121121
UR_LOG_L(getContext()->logger, ERR,
122122
"Failed to copy {} bytes data from host "
123123
"pointer {} to buffer {}",
124-
Size, HostPtr, this);
124+
Size, (void *)HostPtr, this);
125125
return URes;
126126
}
127127
}
@@ -189,7 +189,7 @@ ur_result_t MemBuffer::free() {
189189
ur_result_t URes = getContext()->urDdiTable.USM.pfnFree(Context, Ptr);
190190
if (URes != UR_RESULT_SUCCESS) {
191191
UR_LOG_L(getContext()->logger, ERR, "Failed to free buffer handle {}",
192-
Ptr);
192+
(void *)Ptr);
193193
return URes;
194194
}
195195
}

unified-runtime/source/loader/layers/sanitizer/tsan/tsan_buffer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct MemBuffer {
5959

6060
size_t Size;
6161

62+
// FIXME: we should use uint8_t* instead of char* for non-string data.
6263
char *HostPtr{};
6364

6465
struct SubBuffer_t {

0 commit comments

Comments
 (0)