Skip to content

Commit bf7526b

Browse files
authored
Merge pull request #2059 from pbalcer/trace-try-catch
catch and ignore the exception when SYCL_*_TRACE is malformed
2 parents 9b03077 + 6854e10 commit bf7526b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

source/ur/ur.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ bool PrintTrace = [] {
1717
const char *UrRet = std::getenv("SYCL_UR_TRACE");
1818
const char *PiRet = std::getenv("SYCL_PI_TRACE");
1919
const char *Trace = UrRet ? UrRet : (PiRet ? PiRet : nullptr);
20-
const int TraceValue = Trace ? std::stoi(Trace) : 0;
20+
int TraceValue = 0;
21+
if (Trace) {
22+
try {
23+
TraceValue = std::stoi(Trace);
24+
} catch (...) {
25+
// no-op, we don't have a logger yet to output an error.
26+
}
27+
}
28+
2129
if (TraceValue == -1 || TraceValue == 2) {
2230
return true;
2331
}

0 commit comments

Comments
 (0)