mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-04 04:07:22 +00:00
Fix crash when running ORT under low integrity process like Edge where ETW registration can fail (#22699)
### Description Make ETW provider registration non-fatal and not throw an exception Needs to work under build with exceptions enabled & --disable_exceptions ### Motivation and Context ORT should not crash Addresses #22475. Private tested by filer of that issue
This commit is contained in:
parent
d419df4076
commit
2e4e221da8
2 changed files with 11 additions and 4 deletions
|
|
@ -158,8 +158,9 @@ void EtwRegistrationManager::LazyInitialize() {
|
|||
initialization_status_ = InitializationStatus::Initializing;
|
||||
etw_status_ = ::TraceLoggingRegisterEx(etw_provider_handle, ORT_TL_EtwEnableCallback, nullptr);
|
||||
if (FAILED(etw_status_)) {
|
||||
// Registration can fail when running under Low Integrity process, and should be non-fatal
|
||||
initialization_status_ = InitializationStatus::Failed;
|
||||
ORT_THROW("ETW registration failed. Logging will be broken: " + std::to_string(etw_status_));
|
||||
LOGS_DEFAULT(WARNING) << "Error in ETW registration: " << std::to_string(etw_status_);
|
||||
}
|
||||
initialization_status_ = InitializationStatus::Initialized;
|
||||
}
|
||||
|
|
@ -176,7 +177,9 @@ void EtwRegistrationManager::InvokeCallbacks(LPCGUID SourceId, ULONG IsEnabled,
|
|||
|
||||
std::lock_guard<std::mutex> lock(callbacks_mutex_);
|
||||
for (const auto& callback : callbacks_) {
|
||||
(*callback)(SourceId, IsEnabled, Level, MatchAnyKeyword, MatchAllKeyword, FilterData, CallbackContext);
|
||||
if (callback != nullptr) {
|
||||
(*callback)(SourceId, IsEnabled, Level, MatchAnyKeyword, MatchAllKeyword, FilterData, CallbackContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -735,8 +735,12 @@ InferenceSession::~InferenceSession() {
|
|||
// Unregister the session and ETW callbacks
|
||||
#ifdef _WIN32
|
||||
std::lock_guard<std::mutex> lock(active_sessions_mutex_);
|
||||
WindowsTelemetry::UnregisterInternalCallback(callback_ML_ORT_provider_);
|
||||
logging::EtwRegistrationManager::Instance().UnregisterInternalCallback(callback_ETWSink_provider_);
|
||||
if (callback_ML_ORT_provider_ != nullptr) {
|
||||
WindowsTelemetry::UnregisterInternalCallback(callback_ML_ORT_provider_);
|
||||
}
|
||||
if (callback_ETWSink_provider_ != nullptr) {
|
||||
logging::EtwRegistrationManager::Instance().UnregisterInternalCallback(callback_ETWSink_provider_);
|
||||
}
|
||||
#endif
|
||||
active_sessions_.erase(session_id_);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue