-
Notifications
You must be signed in to change notification settings - Fork 13k
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
std: Fix a bug on the wasm32-wasi target opening files #82804
Conversation
This commit fixes an issue pointed out in rust-lang#82758 where LTO changed the behavior of a program. It turns out that LTO was not at fault here, it simply uncovered an existing bug. The bindings to `__wasilibc_find_relpath` assumed that the relative portion of the path returned was always contained within thee input `buf` we passed in. This isn't actually the case, however, and sometimes the relative portion of the path may reference a sub-portion of the input string itself. The fix here is to use the relative path pointer coming out of `__wasilibc_find_relpath` as the source of truth. The `buf` used for local storage is discarded in this function and the relative path is copied out unconditionally. We might be able to get away with some `Cow`-like business or such to avoid the extra allocation, but for now this is probably the easiest patch to fix the original issue.
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
Also, if possible, I'd like to nominate this for beta inclusion since this is a relatively serious bug for the wasi target |
Reviewed in T-compiler meeting. @bors r+ |
📌 Commit d6b06b8 has been approved by |
beta backport discussed and delegated to T-libs-impl call on this. Approved for nightly. |
std: Fix a bug on the wasm32-wasi target opening files This commit fixes an issue pointed out in rust-lang#82758 where LTO changed the behavior of a program. It turns out that LTO was not at fault here, it simply uncovered an existing bug. The bindings to `__wasilibc_find_relpath` assumed that the relative portion of the path returned was always contained within thee input `buf` we passed in. This isn't actually the case, however, and sometimes the relative portion of the path may reference a sub-portion of the input string itself. The fix here is to use the relative path pointer coming out of `__wasilibc_find_relpath` as the source of truth. The `buf` used for local storage is discarded in this function and the relative path is copied out unconditionally. We might be able to get away with some `Cow`-like business or such to avoid the extra allocation, but for now this is probably the easiest patch to fix the original issue.
⌛ Testing commit d6b06b8 with merge 9e7307ab7817bc4fe561e6d0132326b035530137... |
💥 Test timed out |
@bors retry |
std: Fix a bug on the wasm32-wasi target opening files This commit fixes an issue pointed out in rust-lang#82758 where LTO changed the behavior of a program. It turns out that LTO was not at fault here, it simply uncovered an existing bug. The bindings to `__wasilibc_find_relpath` assumed that the relative portion of the path returned was always contained within thee input `buf` we passed in. This isn't actually the case, however, and sometimes the relative portion of the path may reference a sub-portion of the input string itself. The fix here is to use the relative path pointer coming out of `__wasilibc_find_relpath` as the source of truth. The `buf` used for local storage is discarded in this function and the relative path is copied out unconditionally. We might be able to get away with some `Cow`-like business or such to avoid the extra allocation, but for now this is probably the easiest patch to fix the original issue.
Rollup of 10 pull requests Successful merges: - rust-lang#81465 (Add documentation about formatting `Duration` values) - rust-lang#82121 (Implement Extend and FromIterator for OsString) - rust-lang#82617 (Document `everybody_loops`) - rust-lang#82789 (Get with field index from pattern slice instead of directly indexing) - rust-lang#82798 (Rename `rustdoc` to `rustdoc::all`) - rust-lang#82804 (std: Fix a bug on the wasm32-wasi target opening files) - rust-lang#82943 (Demonstrate best practice for feeding stdin of a child processes) - rust-lang#83066 (Add `reverse` search alias for Iterator::rev()) - rust-lang#83070 (Update cargo) - rust-lang#83081 (Fix panic message of `assert_failed_inner`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Discussed in this week's T-compiler triage meeting. Beta backport approved. |
…imulacrum [stable] 1.51.0 release Also includes backports of the release notes, as well as: * SplitInclusive is public API rust-lang#83372 * std: Fix a bug on the wasm32-wasi target opening files rust-lang#82804 * Fix io::copy specialization using copy_file_range when writer was opened with O_APPEND rust-lang#82417 r? `@Mark-Simulacrum`
This commit fixes an issue pointed out in #82758 where LTO changed the
behavior of a program. It turns out that LTO was not at fault here, it
simply uncovered an existing bug. The bindings to
__wasilibc_find_relpath
assumed that the relative portion of the pathreturned was always contained within thee input
buf
we passed in. Thisisn't actually the case, however, and sometimes the relative portion of
the path may reference a sub-portion of the input string itself.
The fix here is to use the relative path pointer coming out of
__wasilibc_find_relpath
as the source of truth. Thebuf
used forlocal storage is discarded in this function and the relative path is
copied out unconditionally. We might be able to get away with some
Cow
-like business or such to avoid the extra allocation, but for nowthis is probably the easiest patch to fix the original issue.