Skip to content

Commit b5e4aa5

Browse files
committed
fix crash at use-after-free; fix build fail
1 parent 77a0422 commit b5e4aa5

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

source/loader/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ if(UR_ENABLE_SANITIZER)
110110
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/asan_allocator.hpp
111111
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/asan_interceptor.cpp
112112
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/asan_interceptor.hpp
113+
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/asan_libdevice.hpp
113114
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/asan_quarantine.cpp
114115
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/asan_quarantine.hpp
115116
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/asan_report.cpp
116117
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/asan_report.hpp
117118
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/asan_shadow_setup.cpp
118119
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/asan_shadow_setup.hpp
119120
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/common.hpp
120-
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/device_sanitizer_report.hpp
121121
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/stacktrace.cpp
122122
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/stacktrace.hpp
123123
${CMAKE_CURRENT_SOURCE_DIR}/layers/sanitizer/ur_sanddi.cpp

source/loader/layers/sanitizer/asan_report.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,24 @@ void ReportUseAfterFree(const DeviceSanitizerReport &Report,
136136
if (!AllocInfoItOp) {
137137
context.logger.always("Failed to find which chunck {} is allocated",
138138
(void *)Report.Address);
139-
return;
139+
} else {
140+
auto &AllocInfo = (*AllocInfoItOp)->second;
141+
if (AllocInfo->Context != Context) {
142+
context.logger.always("Failed to find which chunck {} is allocated",
143+
(void *)Report.Address);
144+
}
145+
assert(AllocInfo->IsReleased);
146+
147+
context.logger.always("{} is located inside of {} region [{}, {})",
148+
(void *)Report.Address, ToString(AllocInfo->Type),
149+
(void *)AllocInfo->UserBegin,
150+
(void *)AllocInfo->UserEnd);
151+
context.logger.always("allocated here:");
152+
AllocInfo->AllocStack.print();
153+
context.logger.always("released here:");
154+
AllocInfo->ReleaseStack.print();
140155
}
141156

142-
auto &AllocInfo = (*AllocInfoItOp)->second;
143-
if (AllocInfo->Context != Context) {
144-
context.logger.always("Failed to find which chunck {} is allocated",
145-
(void *)Report.Address);
146-
}
147-
assert(AllocInfo->IsReleased);
148-
149-
context.logger.always("{} is located inside of {} region [{}, {})",
150-
(void *)Report.Address, ToString(AllocInfo->Type),
151-
(void *)AllocInfo->UserBegin,
152-
(void *)AllocInfo->UserEnd);
153-
context.logger.always("allocated here:");
154-
AllocInfo->AllocStack.print();
155-
context.logger.always("released here:");
156-
AllocInfo->ReleaseStack.print();
157-
158157
exit(1);
159158
}
160159

0 commit comments

Comments
 (0)