std: fix aliasing bug in UNIX process implementation#138896
Merged
bors merged 2 commits intorust-lang:masterfrom May 23, 2025
Merged
std: fix aliasing bug in UNIX process implementation#138896bors merged 2 commits intorust-lang:masterfrom
bors merged 2 commits intorust-lang:masterfrom
Conversation
Collaborator
|
r? @Noratrieb rustbot has assigned @Noratrieb. Use |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Noratrieb
requested changes
Apr 6, 2025
Member
Noratrieb
left a comment
There was a problem hiding this comment.
looks like we got boxed again 💀. but the fixed implementation is nicer anyways, so that's cool.
but can you add a SAFETY comment to the new unsafe blocks? it does all looks fine to me.
Collaborator
|
☔ The latest upstream changes (presumably #141331) made this pull request unmergeable. Please resolve the merge conflicts. |
Noratrieb
approved these changes
May 22, 2025
Member
Noratrieb
left a comment
There was a problem hiding this comment.
r=me after fixing conflicts
`CStringArray` contained both `CString`s and their pointers. Unfortunately, since `CString` uses `Box`, moving the `CString`s into the `Vec` can (under stacked borrows) invalidate the pointer to the string, meaning the resulting `Vec<*const c_char>` was, from an opsem perspective, unusable. This PR removes removes the `Vec<CString>` from `CStringArray`, instead recreating the `CString`/`CStr` from the pointers when necessary. Also,`CStringArray` is now used for the process args as well, the old implementation was suffering from the same kind of bug.
Member
Author
Collaborator
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
May 23, 2025
std: fix aliasing bug in UNIX process implementation `CStringArray` contained both `CString`s and their pointers. Unfortunately, since `CString` uses `Box`, moving the `CString`s into the `Vec` can (under stacked borrows) invalidate the pointer to the string, meaning the resulting `Vec<*const c_char>` was, from an opsem perspective, unusable. This PR removes removes the `Vec<CString>` from `CStringArray`, instead recreating the `CString`/`CStr` from the pointers when necessary. Also,`CStringArray` is now used for the process args as well, the old implementation was suffering from the same kind of bug.
This was referenced May 23, 2025
bors
added a commit
that referenced
this pull request
May 23, 2025
Rollup of 7 pull requests Successful merges: - #138896 (std: fix aliasing bug in UNIX process implementation) - #140832 (aarch64-linux: Default to FramePointer::NonLeaf) - #141065 (Updated std doctests for wasm) - #141369 (Simplify `format_integer_with_underscore_sep`) - #141374 (make shared_helpers exe function work for both cygwin and non-cygwin hosts) - #141398 (chore: fix typos in comment) - #141457 (Update mdbook to 0.4.50) Failed merges: - #141405 (GetUserProfileDirectoryW is now documented to always store the size) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
that referenced
this pull request
May 23, 2025
Rollup merge of #138896 - joboet:process_noalias, r=Noratrieb std: fix aliasing bug in UNIX process implementation `CStringArray` contained both `CString`s and their pointers. Unfortunately, since `CString` uses `Box`, moving the `CString`s into the `Vec` can (under stacked borrows) invalidate the pointer to the string, meaning the resulting `Vec<*const c_char>` was, from an opsem perspective, unusable. This PR removes removes the `Vec<CString>` from `CStringArray`, instead recreating the `CString`/`CStr` from the pointers when necessary. Also,`CStringArray` is now used for the process args as well, the old implementation was suffering from the same kind of bug.
github-actions bot
pushed a commit
to model-checking/verify-rust-std
that referenced
this pull request
May 26, 2025
std: fix aliasing bug in UNIX process implementation `CStringArray` contained both `CString`s and their pointers. Unfortunately, since `CString` uses `Box`, moving the `CString`s into the `Vec` can (under stacked borrows) invalidate the pointer to the string, meaning the resulting `Vec<*const c_char>` was, from an opsem perspective, unusable. This PR removes removes the `Vec<CString>` from `CStringArray`, instead recreating the `CString`/`CStr` from the pointers when necessary. Also,`CStringArray` is now used for the process args as well, the old implementation was suffering from the same kind of bug.
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.
CStringArraycontained bothCStrings and their pointers. Unfortunately, sinceCStringusesBox, moving theCStrings into theVeccan (under stacked borrows) invalidate the pointer to the string, meaning the resultingVec<*const c_char>was, from an opsem perspective, unusable. This PR removes removes theVec<CString>fromCStringArray, instead recreating theCString/CStrfrom the pointers when necessary. Also,CStringArrayis now used for the process args as well, the old implementation was suffering from the same kind of bug.