onnxruntime icon indicating copy to clipboard operation
onnxruntime copied to clipboard

onnxruntime.dll may fail to run in sandboxed processes on Windows

Open SteveBeckerMSFT opened this issue 1 year ago • 2 comments

When running onnxruntime.dll in a sandboxed process on Windows, for example, in an Edge or Chrome child utility process, the OS API TraceLoggingRegisterEx fails in //onnxruntime/core/platform/windows/logging/etw_sink.cc. This results in an exception, which can fail fast and then crash the process.

Could we please make ETW tracing build configurable or make this failure non-fatal?

Tagging @ivberg who worked on recent ETW changes.

Thank you, Steve Becker Software Engineer, Microsoft

SteveBeckerMSFT avatar Oct 17 '24 04:10 SteveBeckerMSFT

@ivberg Is there a way for the code to check if ETW is available more gracefully? There seems to be a fairly hard assumption that if _WIN32 is defined that ETW could and should always be enabled.

https://github.com/microsoft/onnxruntime/blob/ac98bcae3788a1ad231c4d104af6af91ab6b2785/onnxruntime/core/session/inference_session.cc#L364-L378

skottmckay avatar Oct 17 '24 05:10 skottmckay

This is interesting. I have not heard of this registration issue with sandboxed processes and ETW but will do some research.

Registration just registers the providers with Windows, but it doesn’t mean they are enabled until someone listens for them. Almost all dlls in Windows do it this way during runtime.

I didn’t add the 2 providers including registration but my dynamic logging code makes it easier for them to be invoked and registered / used.

Can you send a dump (and private symbols) my way in an email link?

ivberg avatar Oct 17 '24 05:10 ivberg

We're seeing this error in Edge sandbox process: C:\onnxruntime\onnxruntime\core\platform\windows\logging\etw_sink.cc:162 onnxruntime::logging::EtwRegistrationManager::LazyInitialize ETW registration failed. Logging will be broken: -2147024891

mustjab avatar Oct 23 '24 18:10 mustjab

Resolved with PR

ivberg avatar Nov 02 '24 06:11 ivberg