Skip to content

Commit ec04c27

Browse files
committed
Merge from rustc
2 parents b07c99b + d820eab commit ec04c27

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ Definite bugs found:
580580
* [Weak-memory-induced memory leak in Windows thread-local storage](https://github.com/rust-lang/rust/pull/124281)
581581
* [A bug in the new `RwLock::downgrade` implementation](https://rust-lang.zulipchat.com/#narrow/channel/269128-miri/topic/Miri.20error.20library.20test) (caught by Miri before it landed in the Rust repo)
582582
* [Mockall reading unintialized memory when mocking `std::io::Read::read`, even if all expectations are satisfied](https://github.com/asomers/mockall/issues/647) (caught by Miri running Tokio's test suite)
583+
* [`ReentrantLock` not correctly dealing with reuse of addresses for TLS storage of different threads](https://github.com/rust-lang/rust/pull/141248)
583584

584585
Violations of [Stacked Borrows] found that are likely bugs (but Stacked Borrows is currently just an experiment):
585586

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extern crate tracing;
5353
extern crate rustc_abi;
5454
extern crate rustc_apfloat;
5555
extern crate rustc_ast;
56-
extern crate rustc_attr_parsing;
56+
extern crate rustc_attr_data_structures;
5757
extern crate rustc_const_eval;
5858
extern crate rustc_data_structures;
5959
extern crate rustc_errors;

src/machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rand::rngs::StdRng;
1313
use rand::{Rng, SeedableRng};
1414
use rustc_abi::{Align, ExternAbi, Size};
1515
use rustc_apfloat::{Float, FloatConvert};
16-
use rustc_attr_parsing::InlineAttr;
16+
use rustc_attr_data_structures::InlineAttr;
1717
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1818
#[allow(unused)]
1919
use rustc_data_structures::static_assert_size;

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()> =
9897
unsafe { lib.get(link_name.as_str().as_bytes()).ok()? };
9998
#[expect(clippy::as_conversions)] // fn-ptr to raw-ptr cast needs `as`.
@@ -110,16 +109,17 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
110109
// This code is a reimplementation of the mechanism for getting `dli_fname` in `libloading`,
111110
// from: https://docs.rs/libloading/0.7.3/src/libloading/os/unix/mod.rs.html#411
112111
// using the `libc` crate where this interface is public.
113-
let mut info = std::mem::MaybeUninit::<libc::Dl_info>::uninit();
112+
let mut info = std::mem::MaybeUninit::<libc::Dl_info>::zeroed();
114113
unsafe {
115114
if libc::dladdr(fn_ptr, info.as_mut_ptr()) != 0 {
116115
let info = info.assume_init();
117116
#[cfg(target_os = "cygwin")]
118117
let fname_ptr = info.dli_fname.as_ptr();
119118
#[cfg(not(target_os = "cygwin"))]
120119
let fname_ptr = info.dli_fname;
120+
assert!(!fname_ptr.is_null());
121121
if std::ffi::CStr::from_ptr(fname_ptr).to_str().unwrap()
122-
!= _lib_path.to_str().unwrap()
122+
!= lib_path.to_str().unwrap()
123123
{
124124
return None;
125125
}

tests/many-seeds/reentrant-lock.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![feature(reentrant_lock)]
2+
//! This is a regression test for
3+
//! <https://rust-lang.zulipchat.com/#narrow/channel/269128-miri/topic/reentrant.20lock.20failure.20on.20musl>.
4+
5+
use std::cell::Cell;
6+
use std::sync::ReentrantLock;
7+
use std::thread;
8+
9+
static LOCK: ReentrantLock<Cell<i32>> = ReentrantLock::new(Cell::new(0));
10+
11+
fn main() {
12+
for _ in 0..20 {
13+
thread::spawn(move || {
14+
let val = LOCK.lock();
15+
val.set(val.get() + 1);
16+
drop(val);
17+
});
18+
}
19+
}

0 commit comments

Comments
 (0)