Skip to content
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

Rollup of 5 pull requests #130483

Merged
merged 79 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
79 commits
Select commit Hold shift click to select a range
13e36cf
add new_cyclic_in for rc
Aug 28, 2024
21cb847
fix fmt
Aug 29, 2024
4abb8e2
fix new_cyclic_in for rc
Aug 29, 2024
2383cc9
improve comments
Aug 29, 2024
68169d3
add new_cyclic_in for Arc
Aug 29, 2024
97df334
remove the Clone requirement
Sep 6, 2024
550e55f
Remove duplicate impl
Sep 6, 2024
4db9c01
Renamed variable and fixed comments referring to renamed FileDescriptor
DeSevilla Sep 7, 2024
ff28977
detect when pthread_rwlock_t is moved
Mandragorian Sep 9, 2024
1185eb0
ci: bump actions/checkout to v4
trivikr Sep 9, 2024
d4eeb31
use fd_num for file descriptors, so we can use fd for file description
RalfJung Sep 9, 2024
e6604ea
Auto merge of #3867 - DeSevilla:rename-fd, r=RalfJung
bors Sep 9, 2024
797ddd2
Auto merge of #3872 - trivikr:actions-checkout-v4, r=RalfJung
bors Sep 9, 2024
0aa3fd4
Auto merge of #3871 - Mandragorian:detect_rwlock_move, r=RalfJung
bors Sep 9, 2024
51dbed2
sync methods: pass around places, not pointer-typed operands
RalfJung Sep 9, 2024
218057c
sync: store extra sync primitive data in a Box<dyn Any> so the type c…
RalfJung Sep 9, 2024
0225309
Auto merge of #3874 - RalfJung:sync, r=RalfJung
bors Sep 9, 2024
0d12c58
Preparing for merge from rustc
RalfJung Sep 10, 2024
c78cd65
Merge from rustc
RalfJung Sep 10, 2024
6e70bd4
fmt
RalfJung Sep 10, 2024
79d4cc9
Auto merge of #3876 - RalfJung:rustup, r=RalfJung
bors Sep 10, 2024
4712e57
Preparing for merge from rustc
Sep 11, 2024
19fa141
Merge from rustc
Sep 11, 2024
7e6ce60
also allow illumos to use mmap for its stack guard
RalfJung Sep 11, 2024
59835ae
Auto merge of #3878 - rust-lang:rustup-2024-09-11, r=RalfJung
bors Sep 11, 2024
2f09cac
Preparing for merge from rustc
Sep 12, 2024
93ef7cd
Merge from rustc
Sep 12, 2024
5fc0865
Auto merge of #3879 - rust-lang:rustup-2024-09-12, r=RalfJung
bors Sep 12, 2024
157dd83
Remove an unused piece of logic
oli-obk Sep 8, 2024
e4d0ae9
add non-portable linux pthread initializers to layout sanity check
RalfJung Sep 12, 2024
b7c7a45
enable all pthread tests on Solarish
RalfJung Sep 12, 2024
9621058
Auto merge of #3880 - RalfJung:sync, r=RalfJung
bors Sep 12, 2024
dd01ee7
smoke-test './miri run --dep'
RalfJung Sep 13, 2024
d5ad772
Auto merge of #3883 - RalfJung:miri-run-dep, r=RalfJung
bors Sep 13, 2024
03f14f0
./miri run: directly run binary instead of using 'cargo run'
RalfJung Sep 13, 2024
20862e4
Auto merge of #3881 - RalfJung:miri-run, r=RalfJung
bors Sep 13, 2024
9bab91f
Preparing for merge from rustc
Sep 14, 2024
94d4991
Merge from rustc
Sep 14, 2024
583f358
Auto merge of #3885 - rust-lang:rustup-2024-09-14, r=RalfJung
bors Sep 14, 2024
b6dea9e
detect when pthread_cond_t is moved
Mandragorian Sep 13, 2024
8c4f055
Auto merge of #3884 - Mandragorian:detect_cond_move, r=RalfJung
bors Sep 14, 2024
efdc01b
unix/sync: cleanup
RalfJung Sep 15, 2024
4000027
pthread: add FreeBSD, remove PTHREAD_MUTEX_NORMAL_FLAG hack
RalfJung Sep 15, 2024
2cdf5f7
move two tests to a better location
RalfJung Sep 15, 2024
2ed9188
enable std::sync tests on Solarish
RalfJung Sep 15, 2024
75921d2
Auto merge of #3886 - RalfJung:freebsd-pthread, r=RalfJung
bors Sep 15, 2024
cb445d0
make pthread-threadname nicer with cfg-if
RalfJung Sep 15, 2024
8ee38bf
add Android pthread support
RalfJung Sep 15, 2024
f394c6c
test std::time APIs on FreeBSD and Solarish
RalfJung Sep 15, 2024
5f3bec4
we can test more things on Solarish, and update its status in the README
RalfJung Sep 15, 2024
7d8ee71
Auto merge of #3889 - RalfJung:android-pthread, r=RalfJung
bors Sep 15, 2024
ffcaa7f
Preparing for merge from rustc
Sep 16, 2024
4d824fd
Merge from rustc
Sep 16, 2024
1692d12
fmt
Sep 16, 2024
5b8a18f
fix clippy lints
RalfJung Sep 16, 2024
a0f57d8
Auto merge of #3892 - rust-lang:rustup-2024-09-16, r=RalfJung
bors Sep 16, 2024
9f9f198
Bump ui test
oli-obk Sep 7, 2024
987702f
Refator DependencyBuilder construction
oli-obk Sep 16, 2024
4dabcc3
Fix run --dep
oli-obk Sep 16, 2024
e04dc62
Automatically add/remove labesl when github review (requests) are used
oli-obk Sep 16, 2024
1b25298
Update Trusty target maintainers
randomPoison Sep 16, 2024
472fef6
Revert "Rollup merge of #129749 - krasimirgg:llvm-20-lto, r=nikic"
tmandry Sep 17, 2024
6750f04
Update library/alloc/src/sync.rs
matthewpipie Sep 17, 2024
540b4da
Preparing for merge from rustc
Sep 17, 2024
48440b1
Merge from rustc
Sep 17, 2024
c5f5cfc
fmt
Sep 17, 2024
f6ae3cb
Auto merge of #3866 - rust-lang:ui_test_26_1, r=oli-obk
bors Sep 17, 2024
9c3a392
Auto merge of #3893 - rust-lang:autolabel, r=RalfJung
bors Sep 17, 2024
d0f4a52
Auto merge of #3894 - rust-lang:rustup-2024-09-17, r=RalfJung
bors Sep 17, 2024
143710f
Tokio ICE fix: Changed the type of EpollEventInterest::epfd from i32 …
tiif Sep 17, 2024
b880024
Auto merge of #3891 - tiif:tokiotest, r=RalfJung
bors Sep 17, 2024
ba86cf8
update lockfile
RalfJung Sep 17, 2024
0a25324
Add test for fluent diagnostics
Xiretza Aug 23, 2024
5b3bde9
fluent_macro: fix diagnostics for fluent parse failures
Xiretza Aug 19, 2024
8b36ecb
Rollup merge of #129477 - Xiretza:fix-fluent-diagnostics, r=compiler-…
matthiaskrgr Sep 17, 2024
f6fd305
Rollup merge of #129674 - matthewpipie:rc-arc-new-cyclic-in, r=dtolnay
matthiaskrgr Sep 17, 2024
084e93a
Rollup merge of #130452 - randomPoison:trusty-update-maintainers, r=e…
matthiaskrgr Sep 17, 2024
9087312
Rollup merge of #130467 - RalfJung:miri-sync, r=RalfJung
matthiaskrgr Sep 17, 2024
f8090dd
Rollup merge of #130477 - tmandry:revert-llvm-20-lto, r=tmandry
matthiaskrgr Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/tools/miri/src/shims/unix/linux/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 51,9 @@ impl EpollEventInstance {
#[derive(Clone, Debug)]
pub struct EpollEventInterest {
/// The file descriptor value of the file description registered.
/// This is only used for ready_list, to inform userspace which FD triggered an event.
/// For that, it is crucial to preserve the original FD number.
/// This FD number must never be "dereferenced" to a file description inside Miri.
fd_num: i32,
/// The events bitmask retrieved from `epoll_event`.
events: u32,
Expand All @@ -61,8 64,8 @@ pub struct EpollEventInterest {
data: u64,
/// Ready list of the epoll instance under which this EpollEventInterest is registered.
ready_list: Rc<RefCell<BTreeMap<(FdId, i32), EpollEventInstance>>>,
/// The file descriptor value that this EpollEventInterest is registered under.
epfd_num: i32,
/// The epoll file description that this EpollEventInterest is registered under.
weak_epfd: WeakFileDescriptionRef,
}

/// EpollReadyEvents reflects the readiness of a file description.
Expand Down Expand Up @@ -343,7 346,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
events,
data,
ready_list: Rc::clone(ready_list),
epfd_num: epfd_value,
weak_epfd: epfd.downgrade(),
}));

if op == epoll_ctl_add {
Expand Down Expand Up @@ -553,12 556,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
if is_updated {
// Edge-triggered notification only notify one thread even if there are
// multiple threads block on the same epfd.
let epfd = this.machine.fds.get(epoll_interest.borrow().epfd_num).unwrap();

// This unwrap can never fail because if the current epoll instance were
// closed and its epfd value reused, the upgrade of weak_epoll_interest
// closed, the upgrade of weak_epoll_interest
// above would fail. This guarantee holds because only the epoll instance
// holds a strong ref to epoll_interest.
let epfd = epoll_interest.borrow().weak_epfd.upgrade().unwrap();
// FIXME: We can randomly pick a thread to unblock.
if let Some(thread_id) =
epfd.downcast::<Epoll>().unwrap().thread_id.borrow_mut().pop()
Expand Down
38 changes: 38 additions & 0 deletions src/tools/miri/tests/pass-dep/libc/libc-epoll-no-blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 23,7 @@ fn main() {
test_ready_list_fetching_logic();
test_epoll_ctl_epfd_equal_fd();
test_epoll_ctl_notification();
test_issue_3858();
}

// Using `as` cast since `EPOLLET` wraps around
Expand Down Expand Up @@ -683,3 684,40 @@ fn test_epoll_ctl_notification() {
// for this epfd, because there is no I/O event between the two epoll_wait.
check_epoll_wait::<1>(epfd0, &[]);
}

// Test for ICE caused by weak epoll interest upgrade succeed, but the attempt to retrieve
// the epoll instance based on the epoll file descriptor value failed. EpollEventInterest
// should store a WeakFileDescriptionRef instead of the file descriptor number, so if the
// epoll instance is duped, it'd still be usable after `close` is called on the original
// epoll file descriptor.
// https://github.com/rust-lang/miri/issues/3858
fn test_issue_3858() {
// Create an eventfd instance.
let flags = libc::EFD_NONBLOCK | libc::EFD_CLOEXEC;
let fd = unsafe { libc::eventfd(0, flags) };

// Create an epoll instance.
let epfd = unsafe { libc::epoll_create1(0) };
assert_ne!(epfd, -1);

// Register eventfd with EPOLLIN | EPOLLET.
let mut ev = libc::epoll_event {
events: (libc::EPOLLIN | libc::EPOLLET) as _,
u64: u64::try_from(fd).unwrap(),
};
let res = unsafe { libc::epoll_ctl(epfd, libc::EPOLL_CTL_ADD, fd, &mut ev) };
assert_eq!(res, 0);

// Dup the epoll instance.
let newfd = unsafe { libc::dup(epfd) };
assert_ne!(newfd, -1);

// Close the old epoll instance, so the new FD is now the only FD.
let res = unsafe { libc::close(epfd) };
assert_eq!(res, 0);

// Write to the eventfd instance.
let sized_8_data: [u8; 8] = 1_u64.to_ne_bytes();
let res = unsafe { libc::write(fd, sized_8_data.as_ptr() as *const libc::c_void, 8) };
assert_eq!(res, 8);
}
Loading