{{ message }}
Repository navigation
[OpenTelemetry] Fix LogRecord returned to pool twice - #7965
Merged
martincostello merged 3 commits intoOct 16, 2026
Merged
Conversation
Only return the current `LogRecord` to the shared pool when a batch enumerator is disposed early if the batch owns a reference to it. Assisted-by: Claude Code (Claude Opus 5.5) <noreply@anthropic.com> Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-9R51ZCPL.
Add PR number. Assisted-by: Claude Code (Claude Opus 5.5) <noreply@anthropic.com> Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-9R51ZCPL.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrow ownership guard and targeted regression tests address the reported failure with no unresolved findings.
0 open findings
What changed in this PR
Fixes premature LogRecord pool returns that could corrupt data queued for batch export.
Changes:
- Limits enumerator pool cleanup to circular-buffer batches.
- Adds ownership and mixed-processor regression tests.
- Documents the fix in the SDK changelog.
[!NOTE]
This review was generated with GitHub Copilot.
| File | Description |
|---|---|
| test/OpenTelemetry.Tests/Trace/BatchTests.cs | Tests caller-owned and batch-owned record cleanup. |
| test/OpenTelemetry.Tests/Logs/BatchLogRecordExportProcessorTests.cs | Tests early exporter exit with both processor orders. |
| src/OpenTelemetry/CHANGELOG.md | Documents the pooling fix. |
| src/OpenTelemetry/Batch.cs | Restricts pool returns to circular-buffer batches. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
martincostello
marked this pull request as ready for review
October 16, 2026 16:43
martincostello
enabled auto-merge
October 16, 2026 16:43
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7965 +/- ##
==========================================
+ Coverage 92.37% 92.39% +0.01%
==========================================
Files 365 365
Lines 21185 21185
==========================================
+ Hits 19569 19573 +4
+ Misses 1616 1612 -4
Flags with carried forward coverage won't be shown. Click here to find out more. |
matt-hensley
approved these changes
Oct 16, 2026
This was referenced Oct 20, 2026
This was referenced Oct 28, 2026
Open
Closed
This was referenced Oct 28, 2026
Open
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-9R51ZCPL.
Changes
Fix
LogRecordinstances being returned to the shared pool while they are still queued for export.Batch<T>.Enumerator.Dispose()returned the currentLogRecordtoLogRecordSharedPoolfor every kind ofBatch<LogRecord>, but only batches read from the circular buffer of aBatchLogRecordExportProcessorown a pool reference to their records. When an exporter behind aSimpleLogRecordExportProcessorstopped enumerating its single-item batch early (for example by returningExportResult.Failurefrom inside theforeach), the logger's only reference was released. The record was then cleared and reused while aBatchLogRecordExportProcessoron the same provider still had it queued, so the batch exporter could export records with missing or mixed-up attributes.The enumerator now only returns the current record to the pool when the batch was read from a circular buffer, which matches the guard
Batch<T>.Dispose()already uses.Merge requirement checklist
CHANGELOG.mdfile(s) updated for non-trivial changesChanges in public API reviewed (if applicable)Note
The changes in this PR and its description were generated with Claude Code (Claude Opus 5.5).
Footnotes
Yes, I can answer maintainer questions about the content of this PR without using AI. ↩