fix(profiling): fix invalid access in GenInfo::create_impl#17038
Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit intoMar 20, 2026
Merged
Conversation
Codeowners resolved as |
Co-authored-by: KowalskiThomas <14239160+KowalskiThomas@users.noreply.github.com>
236bdfa to
998abc6
Compare
GenInfo::createGenInfo::create_impl
taegyunkim
approved these changes
Mar 20, 2026
Contributor
Author
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
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.
Description
https://datadoghq.atlassian.net/browse/PROF-13112
This fixes a segmentation fault / invalid memory read I discovered through Crash Logs.
The problem is similar to others we've already seen in the past;
f->f_lastiwas used to index into a bytecode buffer, butfwas a "real" pointer and not acopy_memory'd one.Since we don't hold the GIL is not held during sampling, this is possibly an invalid read, which seems to happen rarely (I had never seen this before) but can happen.
This should only have happened on Python < 3.11 given what code it is, but it's still worth fixing.
Additionally, neither the Python < 3.10 nor the Python 3.10 code paths performed bounds checking on the computed bytecode index before accessing the
c[]buffer. With stale frame data,frame.f_lastican be an arbitrary value, leading to an out-of-bounds read on the locally-allocated bytecode buffer.Risks
This should remove risks more than it adds. As far as I can tell, it is safe as the only changes are for reading local memory as opposed to unsafe memory.