Attempt to prevent crash in TelemetryTraceLogger::InitializeInternal()
#3527
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have been getting reports of heap corruption crashes on
AppInstaller::Logging::TelemetryTraceLogger::InitializeInternal
in calls to the COM API, with a recent spike in number of hits.This is probably due to trying to initialize the trace logger from two places at the same time
, so I'm adding synchronization there.I was unable to get a repro to confirm this was the issue and test that the change fixed it, so it may not actually do anything. See https://task.ms/38253096
Microsoft Reviewers: Open in CodeFlow
Edit: Changed per @JohnMcPMS suggestion.
m_isSettingEnabled
aCopyConstructibleAtomic<bool>
m_isSettingEnabled
default value tofalse
, so that we only set it totrue
after successfully readin the settingsm_userProfile
to be a static inAnonymizeString()
. This function is only called when emitting an event, and that happens only if we finished the initialization, which ensures that the use of the settings when getting the user profile path is safe.