-
Notifications
You must be signed in to change notification settings - Fork 2
Fix Data Corruption From Internal Buffer Aliasing #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pashneal
merged 2 commits into
main
from
neal.powell/CLOUDS-7101/CLOUDS-7233/CLOUDS-7238/fix.memory.corruption.from.internal.buffer
Feb 2, 2026
Merged
Fix Data Corruption From Internal Buffer Aliasing #436
pashneal
merged 2 commits into
main
from
neal.powell/CLOUDS-7101/CLOUDS-7233/CLOUDS-7238/fix.memory.corruption.from.internal.buffer
Feb 2, 2026
+38
−1
Conversation
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
Coverage ReportControl Plane Coverage:
Forwarder Coverage:
|
agulen
approved these changes
Jan 30, 2026
mattsp1290
approved these changes
Jan 30, 2026
Member
mattsp1290
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! nice catch!
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.
Description
This PR fixes an issue seen in customer environments where logs forwarded are corrupted/malformed.
Because the internal
[]bytebuffer underbufio.Scanner.Bytes()is possibly mutated on each call tobufio.Scanner.Scan(), it is not safe to reuse that[]byteslice directly as was done throughLog.Contentwhen PII rules were not set. On large enough logs,bufio.Scanneroverwrites the buffer - and thereforeLog.Contentcontained junk data.This affected 2%-3% of forwarded logs for a number of customers - and is the root cause of some additional issues.
Visual Explanation
bufio.Scanner.Bytes()returns a slice pointing directly into the scanner's internal buffer - not a copy. The buffer is 5MB; when total scanned data exceeds this, the buffer wraps and earlier entries get overwritten.Step 1: Scanning Fills Buffer (total data < 5MB)
Scanner Internal Buffer (5MB):
{"data":"AAAA"}{"data":"BBBB"}logs[].Content:
{"data":"AAAA"}{"data":"BBBB"}Step 2: Buffer Wraps (total data > 5MB)
The buffer fills up and is forced to overwrite earlier segments of the buffer to avoid allocation.
Scanner Internal Buffer (5MB):
{"data":"CCCCCCCCCCCCCCCCCC"}logs[].Content:
{"data":"CCCCCCCCCCCCCCCC"}All
Log.Contentslices point into the same 5MB buffer. Once input exceeds buffer capacity, new data spills back to the start - and longer entries overflow into adjacent memory, corrupting multiple earlier entries at once.Fix
To fix this issue, we clone the data for each log instead of reusing the direct slice from
bufio.Scanner.Bytes().Metadata
Jira issue:
This change affects:
Testing
A regression test verifying the behavior is fixed has been added. All other test pass.
Rollout