onnxruntime icon indicating copy to clipboard operation
onnxruntime copied to clipboard

Cherry-pick b341c44: Fix ETW trace logging crash in multithreading situations (#21566)

Open aamajumder opened this issue 1 year ago • 0 comments

Description

ETW trace logger is fakely registered as initialized_ is marked as true before the registration is done, causing crashing issue for Lenovo camera application.

A prior attempt to address was made here: https://github.com/microsoft/onnxruntime/pull/21226 It was reverted here: https://github.com/microsoft/onnxruntime/pull/21360

Motivation and Context

The problem is that during initialization of TraceLoggingRegisterEx, it will reinvoke the callback and attempt reinitialization, which is not allowed. TraceLoggingRegisterEx however can be initialized concurrently when initialization happens on multiple threads. For these reasons it needs to be protected by a lock, but the lock cannot naively block because the callback's reinvocation will cause a deadlock.

To solve this problem another tracking variable is added : "initializing" which protects against reinitialization during the first initialization.


Description

Motivation and Context

aamajumder avatar Oct 14 '24 23:10 aamajumder