Repository navigation
Fix OOM from unbounded enumeration of ExtendedLogger tag joiners - #7819
Merged
evgenyfedorov2 merged 1 commit intoOct 9, 2026
Merged
Conversation
evgenyfedorov2
force-pushed
the
evgenyfedorov2-fix-tag-joiner-self-enumeration-oom
branch
from
October 8, 2026 12:04
2e55a3b to
97ec24b
Compare
LegacyTagJoiner and ModernTagJoiner enumerated their tags with a loop bounded
by Count, which includes the joiner's extra tags. When a joiner was enumerated
while tags were being added to that same list, the enumeration never ended and
memory grew until an OutOfMemoryException. This happens, for example, when a
logging provider forwards a lazily wrapped log state to another extended logger
on the same thread, because all extended loggers on a thread share one joiner.
The enumerators now capture the number of extra tags when enumeration starts
and iterate each group of tags separately, in the same order as the indexer, so
that "{OriginalFormat}" remains the last tag.
Fixes #7505
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
evgenyfedorov2
force-pushed
the
evgenyfedorov2-fix-tag-joiner-self-enumeration-oom
branch
from
October 8, 2026 12:06
97ec24b to
d57bfbb
Compare
evgenyfedorov2
marked this pull request as ready for review
October 8, 2026 12:07
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Both implementations address the reported failure and include focused regression tests; tests were not executed.
0 open findings
What changed in this PR
Fixes #7505 by preventing unbounded self-enumeration in ExtendedLogger tag joiners, avoiding out-of-memory failures.
Changes:
- Bounds enumeration of enrichment tags while preserving tag order.
- Adds regression tests for both joiners, capped to prevent runaway memory use.
| File | Description |
|---|---|
| test/Libraries/Microsoft.Extensions.Telemetry.Tests/Logging/TagJoinerTests.cs | Adds bounded self-enumeration regression tests. |
| src/Libraries/Microsoft.Extensions.Telemetry/Logging/ExtendedLogger.ModernTagJoiner.cs | Enumerates tag groups with a fixed enrichment-tag count. |
| src/Libraries/Microsoft.Extensions.Telemetry/Logging/ExtendedLogger.LegacyTagJoiner.cs | Separates incoming-tag count and bounds enrichment-tag enumeration. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Collaborator
🎉 Good job! The coverage increased 🎉
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1628008&view=codecoverage-tab |
iliar-turdushev
approved these changes
Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes: #7505
Microsoft Reviewers: Open in CodeFlow