[release/6.0] Make sure EventPipe streaming thread won't write session->streaming_thread after session free. #58710
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.
Backport of #58615 to release/6.0
/cc @lateralusX
Customer Impact
Race condition writing to memory after free causing rare, but hard to diagnose runtime AV's. Only reproduced on CI so far only seen on CoreCLR, but could happen on all platforms, including platforms handled by MonoVM. Crash described in several issues like #57461.
Testing
Have been hit on CI multiple times over the last 3 week's, so we should have CI test cases the runs this code path very frequently (since the window for this race condition is small).
Risk
Low, we have many CI tests cover this code path and resetting the memory area to NULL is currently done to preventing future issues if we add logic acting on this field (like restart streaming on existing session using a different streaming thread), so no code currently depends on the value written into the field and therefore not affected.