-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Regression in File::read_to_end on 1.57.0 Nightly #90263
Comments
It does not crash on my PC, which is What kind of ARM device are you using? I will try it on my Raspberry Pi 4 tonight. |
The crashes are occuring on two aarch64 virtual machines of Ubuntu 20.04 ARM LTS (Parallels running on Apple M1). It's interesting that the behavior isn't on x86_64, I'll check on my x86_64 device now. |
Reproduced on Ubuntu 20.04 x86_64 LTS.
|
I can reproduce it on my WSL2 machine running Linux 5.10.16 x86_64. |
The segfault is coming from the code I added to Tracing through to the crash location, it is segfaulting in a function called rust/library/std/src/sys/unix/fs.rs Lines 135 to 141 in 3c8f001
For context, this code tries to get file metadata on Linux by calling the This code works perfectly fine in normal circumstances, however in the Other notes:
|
This can be reproduced by calling // init_rtld_audit_interface
#[used]
#[allow(non_upper_case_globals)]
#[link_section = ".init_array"]
static init_rtld_audit_interface: unsafe extern "C" fn(i32, *const *const i8, *const *const i8) = {
#[link_section = ".text.startup"]
unsafe extern "C" fn init_rtld_audit_interface(
_argc: i32,
_argv: *const *const i8,
_envp: *const *const i8,
) {
let _ = std::fs::metadata("");
}
init_rtld_audit_interface
};
// la_version
#[no_mangle]
unsafe extern "C" fn la_version(version: u32) -> u32 {
version
} |
Source of the |
We discussed this in the @rust-lang/libs meeting just now. We decided to prioritize this as P-medium, since it's not clear if this is triggerable in any supported environment. We didn't have the chance to investigate in detail, but one guess is that using Depending on any new discoveries on when this issue appears, we can raise or lower the priority. |
Indeed, the call to rust/library/std/src/sys/unix/weak.rs Lines 96 to 102 in 4e0d397
|
@jkugelman That was some truly impressive tracing through the source. If the dlsym call is segfaulting, I believe the problem will lie in ld (in glibc). To confirm, I'll port the initial test case to C and see if it segfaults in the same location by doing a dlsym of statx. If so, I'd like to close this issue. I'll keep you all posted. |
Thanks. I spent hours digging into the guts of |
I can fairly easily imagine ways we could fix this specific incarnation of this issue. For instance, this optimization doesn't really need statx. However, we don't in general make guarantees about the exact syscalls or library functions we call. I personally think the LD_AUDIT interface may be sufficiently specialized that we can't necessarily guarantee Rust functions will remain within the constraints of what's necessary to be called in that context. |
We discussed this again in today's @rust-lang/libs meeting. We agreed that, in general, we're not prepared to keep all of the standard library within the limitations required to implement an However, we'd absolutely be amenable in general to alternatives to |
The specific problem there was #23628 because we use For everything else we use as a weak symbol, I think it would be fine for those to resolve to a normal I'm basically suggesting that we could keep the |
See #90846 for an attempt at weak linkage. |
PR #89582 (commit 910692d) created a regression in File::read_to_end on the Rust Nightly channel (1.57.0 Nightly). This is before main(), it impacts cdylib projects.
Code
lib.rs
Cargo.toml
Makefile
I expected to see this happen: (no output)
Instead, this happened: Segmentation fault
Version it worked on
It most recently worked on: Rust 1.57.0-nightly, nightly-2021-10-09-aarch64-unknown-linux-gnu
Version with regression
Regression occurred in: Rust 1.57.0-nightly, nightly-2021-10-10-aarch64-unknown-linux-gnu
rustc --version --verbose
:@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged
The text was updated successfully, but these errors were encountered: