Skip to content

Commit fafd9cf

Browse files
authored
[SYCL][UR][L0 v2] Coverity fixes (#19489)
- catch potential exception in ~ur_exp_command_buffer_handle_t_ - move ZeUSMImport definition to adapter.cpp: ZeUSMImport is used by global adapter constructor (on Windows). It needs to be initialized before the global adapter. According to Coverity: The constructor of global object "GlobalAdapter" itself makes use of global object "ZeUSMImport" defined in another compilation unit. The order of construction is unspecified, so "GlobalAdapter" might be created before "ZeUSMImport" is available.
1 parent 4cd7f7c commit fafd9cf

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

unified-runtime/source/adapters/level_zero/adapter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <umf.h>
2222
#endif
2323

24+
ZeUSMImportExtension ZeUSMImport;
25+
2426
// Due to multiple DLLMain definitions with SYCL, Global Adapter is init at
2527
// variable creation.
2628
#if defined(_WIN32)

unified-runtime/source/adapters/level_zero/common.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ bool setEnvVar(const char *name, const char *value) {
8484
return true;
8585
}
8686

87-
ZeUSMImportExtension ZeUSMImport;
88-
8987
void zeParseError(ze_result_t ZeError, const char *&ErrorString) {
9088
switch (ZeError) {
9189
#define ZE_ERRCASE(ERR) \

unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ ur_result_t ur_exp_command_buffer_handle_t_::registerExecutionEventUnlocked(
166166
return UR_RESULT_SUCCESS;
167167
}
168168

169-
ur_exp_command_buffer_handle_t_::~ur_exp_command_buffer_handle_t_() {
169+
ur_exp_command_buffer_handle_t_::~ur_exp_command_buffer_handle_t_() try {
170170
UR_CALL_NOCHECK(commandListManager.lock()->releaseSubmittedKernels());
171171

172172
if (currentExecution) {
@@ -175,6 +175,9 @@ ur_exp_command_buffer_handle_t_::~ur_exp_command_buffer_handle_t_() {
175175
for (auto &event : syncPoints) {
176176
event->release();
177177
}
178+
} catch (...) {
179+
UR_LOG(DEBUG, "ur_exp_command_buffer_handle_t_ destructor failed with: {}",
180+
exceptionToResult(std::current_exception()));
178181
}
179182

180183
ur_result_t ur_exp_command_buffer_handle_t_::applyUpdateCommands(

0 commit comments

Comments
 (0)