Skip to content

Commit 64a4115

Browse files
committed
Auto merge of #141243 - Zalathar:rollup-x5xt80l, r=Zalathar
Rollup of 5 pull requests Successful merges: - #140847 (coverage: Detect unused local file IDs to avoid an LLVM assertion) - #141117 (opt-dist: fix deprecated BOLT -icf=1 option) - #141225 (more ice tests) - #141239 (dladdr cannot leave dli_fname to be null) - #141242 (in `tests/ui/asm/aarch64/parse-error.rs`, only test cases specific to that target) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5ac0fec + 15ab0b2 commit 64a4115

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/shims/native_lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
9292
fn get_func_ptr_explicitly_from_lib(&mut self, link_name: Symbol) -> Option<CodePtr> {
9393
let this = self.eval_context_mut();
9494
// Try getting the function from the shared library.
95-
// On windows `_lib_path` will be unused, hence the name starting with `_`.
96-
let (lib, _lib_path) = this.machine.native_lib.as_ref().unwrap();
95+
let (lib, lib_path) = this.machine.native_lib.as_ref().unwrap();
9796
let func: libloading::Symbol<'_, unsafe extern "C" fn()> = unsafe {
9897
match lib.get(link_name.as_str().as_bytes()) {
9998
Ok(x) => x,
@@ -114,16 +113,17 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
114113
// This code is a reimplementation of the mechanism for getting `dli_fname` in `libloading`,
115114
// from: https://docs.rs/libloading/0.7.3/src/libloading/os/unix/mod.rs.html#411
116115
// using the `libc` crate where this interface is public.
117-
let mut info = std::mem::MaybeUninit::<libc::Dl_info>::uninit();
116+
let mut info = std::mem::MaybeUninit::<libc::Dl_info>::zeroed();
118117
unsafe {
119118
if libc::dladdr(*func.deref() as *const _, info.as_mut_ptr()) != 0 {
120119
let info = info.assume_init();
121120
#[cfg(target_os = "cygwin")]
122121
let fname_ptr = info.dli_fname.as_ptr();
123122
#[cfg(not(target_os = "cygwin"))]
124123
let fname_ptr = info.dli_fname;
124+
assert!(!fname_ptr.is_null());
125125
if std::ffi::CStr::from_ptr(fname_ptr).to_str().unwrap()
126-
!= _lib_path.to_str().unwrap()
126+
!= lib_path.to_str().unwrap()
127127
{
128128
return None;
129129
}

0 commit comments

Comments
 (0)