-
Notifications
You must be signed in to change notification settings - Fork 15
FFL-1450 fix memory corruption in flag_metadata #1368
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
base: main
Are you sure you want to change the base?
Conversation
BenchmarksComparisonBenchmark execution time: 2025-11-24 21:01:13 Comparing candidate commit 067fd56 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 55 metrics, 2 unstable metrics. CandidateCandidate benchmark detailsGroup 1
Group 2
Group 3
Group 4
Group 5
Group 6
Group 7
Group 8
Group 9
Group 10
Group 11
Group 12
Group 13
Group 14
Group 15
Group 16
Group 17
BaselineOmitted due to size. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1368 +/- ##
=======================================
Coverage 71.19% 71.20%
=======================================
Files 392 392
Lines 62677 62751 +74
=======================================
+ Hits 44626 44684 +58
- Misses 18051 18067 +16
🚀 New features to boost your workflow:
|
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-apple-darwin
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-apple-darwin
x86_64-unknown-linux-gnu
|
| .map(|(k, v)| { | ||
| KeyValue { | ||
| // SAFETY: the borrow is valid as long as string allocation is | ||
| // alive. ResolutionDetails will get moved into heap but this does not |
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.
Ok I think I understand. ResolutionDetails moves, and since Assignment is owned directly by the struct due to inner: Result<Assignment, EvaluationError>, Assignment moves too. So,
let details = ResolutionDetails::new(Ok(value)); // details created
// BorrowedStr pointers in details are valid
let moved_details = details; // move happens
// now BorrowedStr pointers in moved_details are invalid
Thanks for updating the comments! They're helpful
What does this PR do?
Fix a memory corruption bug in flag_metadata.
Additional Notes
Strtype has small string optimization, whereas short strings are stored directly in the structure bytes instead of on heap. This means that taking a reference to anallocation_keystring was pointing to an str structure which was stored on stack at that time and was moved out when result was returned from the structure. When trying to printflag_metadata.allocationKey, it was printing garbage bytes from stack.This PR stores result on heap first (
Box) and pins it for extra measure, to make sure it's not moved. This allows us to create stable pointers toallocation_key.How to test the change?
Example was expanded to print flag metadata, so verified that it was corrupted before / fixed after the change.