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 9 pull requests #123910

Closed
wants to merge 24 commits into from

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

tgross35 and others added 24 commits April 8, 2024 17:43
The `thread_local!` examples use `RefCell` for `Copy` types. Update
examples to have one `Copy` and one non-`Copy` type using `Cell` and
`RefCell`, respectively.
Reduce `unsafe` block scope and add `SAFETY` comments.
This is in accordance with Clippy's redundant_closure_for_method_calls.
Original diff from @notgull in rust-lang#118349, small changes from me.

on OpenBSD, getsockname(2) returns the actual size of the socket address, and 
not the len of the content. Figure out the length for ourselves.
see https://marc.info/?l=openbsd-bugs&m=170105481926736&w=2

Fixes rust-lang#116523
Luckily it's comparatively simple to just restore the `VecDeque` into a valid state on unwinds.
This change makes tidy to handle run-make checks with a single iteration,
avoiding the need for multiple iterations and copying.

Signed-off-by: onur-ozkan <[email protected]>
Add a helper macro for adding common methods to command wrappers. Common
methods include helpers that delegate to `Command` and running methods.

- `arg` and `args` (delegates to `Command`)
- `env`, `env_remove` and `env_clear` (delegates to `Command`)
- `output`, `run` and `run_fail`

This helps to avoid needing to copy-pasta / reimplement these common
methods on a new command wrapper, which hopefully reduces the friction
for run-make test writers wanting to introduce new command wrappers.
Removes the manual copy-pasta'd implementation of common methods.
…ark-Simulacrum

Thread local updates for idiomatic examples

Update thread local examples to make more idiomatic use of `Cell` for `Copy` types, `RefCell` for non-`Copy` types.

Also shrink the size of `unsafe` blocks, add `SAFETY` comments, and fix `clippy::redundant_closure_for_method_calls`.
…mulacrum

run-make-support: tidy up support library

- Make `handle_failed_output` take `&Command` instead of having the caller keep doing `format!("{:#?}", s)`.
- Introduce a helper macro for implementing common command wrappers, such as `arg`, `args`, `run`, `run_fail`.
    - Use the helper macro on existing command wrappers and remove manual copy-pasta'd implementations.
…Mark-Simulacrum

OpenBSD fix long socket addresses

Original diff from `@notgull` in rust-lang#118349, small changes from me.

on OpenBSD, getsockname(2) returns the actual size of the socket address, and  not the len of the content. Figure out the length for ourselves. see https://marc.info/?l=openbsd-bugs&m=170105481926736&w=2

Fixes rust-lang#116523
…acrum

Fix `VecDeque::shrink_to` UB when `handle_alloc_error` unwinds.

Fixes rust-lang#123369

For `VecDeque` it's relatively simple to restore the buffer into a consistent state so this PR does just that.

Note that with its current implementation, `shrink_to` may change the internal arrangement of elements in the buffer, so e.g. `[D, <uninit>, A, B, C]` will become `[<uninit>, A, B, C, D]` and `[<uninit>, <uninit>, A, B, C]` may become `[B, C, <uninit>, <uninit>, A]` if `shrink_to` unwinds. This shouldn't be an issue though as we don't make any guarantees about the stability of the internal buffer arrangement (and this case is impossible to hit on stable anyways).

This PR also includes a test with code adapted from rust-lang#123369 which fails without the new `shrink_to` code. Does this suffice or do we maybe need more exhaustive tests like in rust-lang#108475?

cc `@Amanieu`

`@rustbot` label +T-libs
Doc: replace x with y for hexa-decimal fmt

I found it a bit unintuitive to know which is variable and which is the format string in `format!("{x:x}")`, so I switched it to `y`.
…mulacrum

Add missing `unsafe` to some internal `std` functions

Adds `unsafe` to a few internal functions that have safety requirements but were previously not marked as `unsafe`. Specifically:

- `std::sys::pal::unix::thread::min_stack_size` needs to be `unsafe` as `__pthread_get_minstack` might dereference the passed pointer. All callers currently pass a valid initialised `libc::pthread_attr_t`.
- `std::thread::Thread::new` (and `new_inner`) need to be `unsafe` as it requires the passed thread name to be valid UTF-8, otherwise `Thread::name` will trigger undefined behaviour. I've taken the opportunity to split out the unnamed thread case into a separate `new_unnamed` function to make the safety requirement clearer. All callers meet the safety requirement now that rust-lang#123505 has been merged.
…mulacrum

reduce tidy overheads in run-make checks

This change makes tidy to handle run-make checks with a single iteration, avoiding the need for multiple iterations and copying.
…, r=compiler-errors

Generic associated consts: Check regions earlier when comparing impl with trait item def

Fixes rust-lang#123836.

r? compiler-errors or compiler
…lacrum

compiletest: Update rustfix to 0.8.1

This updates the version of rustfix used in compiletest to be closer to what cargo is using. This is to help ensure `cargo fix` and compiletest are aligned. There are some unpublished changes to `rustfix`, which will update in a future PR when those are published.

Will plan to update ui_test in the near future to avoid the duplicate.
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 14, 2024
@rustbot rustbot added the rollup A PR which is a rollup label Apr 14, 2024
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=9

@bors
Copy link
Contributor

bors commented Apr 14, 2024

📌 Commit 504f534 has been approved by matthiaskrgr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 14, 2024
@bors
Copy link
Contributor

bors commented Apr 14, 2024

⌛ Testing commit 504f534 with merge 9524b6e...

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 14, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#123651 (Thread local updates for idiomatic examples)
 - rust-lang#123699 (run-make-support: tidy up support library)
 - rust-lang#123779 (OpenBSD fix long socket addresses)
 - rust-lang#123803 (Fix `VecDeque::shrink_to` UB when `handle_alloc_error` unwinds.)
 - rust-lang#123875 (Doc: replace x with y for hexa-decimal fmt)
 - rust-lang#123879 (Add missing `unsafe` to some internal `std` functions)
 - rust-lang#123889 (reduce tidy overheads in run-make checks)
 - rust-lang#123898 (Generic associated consts: Check regions earlier when comparing impl with trait item def)
 - rust-lang#123902 (compiletest: Update rustfix to 0.8.1)

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-aux failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test collections::vec_deque::tests::test_rotate_left_right ... ok
test collections::vec_deque::tests::test_rotate_right_panic ... ok
test collections::vec_deque::tests::test_shrink_to ... ok
test collections::vec_deque::tests::test_shrink_to_fit ... ok
error: unsupported operation: can't call (diverging) foreign function: __rust_alloc_error_handler
     |
385  |             __rust_alloc_error_handler(layout.size(), layout.align());
385  |             __rust_alloc_error_handler(layout.size(), layout.align());
     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call (diverging) foreign function: __rust_alloc_error_handler
     = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
     = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
     = note: BACKTRACE on thread `collections::ve`:
     = note: inside `std::alloc::handle_alloc_error::rt_error` at /checkout/library/alloc/src/alloc.rs:385:13: 385:70
     = note: inside `std::alloc::handle_alloc_error` at /checkout/library/alloc/src/alloc.rs:391:9: 391:75
note: inside `raw_vec::handle_error`
     |
     |
594  |         AllocError { layout, .. } => handle_alloc_error(layout),
note: inside `raw_vec::RawVec::<i32, collections::vec_deque::tests::test_shrink_to_unwind::BadAlloc>::shrink_to_fit`
    --> library/alloc/src/raw_vec.rs:434:13
     |
434  |             handle_error(err);
434  |             handle_error(err);
     |             ^^^^^^^^^^^^^^^^^
note: inside `collections::vec_deque::VecDeque::<i32, collections::vec_deque::tests::test_shrink_to_unwind::BadAlloc>::shrink_to`
    --> library/alloc/src/collections/vec_deque/mod.rs:1055:9
     |
1055 |         guard.deque.buf.shrink_to_fit(target_cap);
note: inside `collections::vec_deque::VecDeque::<i32, collections::vec_deque::tests::test_shrink_to_unwind::BadAlloc>::shrink_to_fit`
    --> library/alloc/src/collections/vec_deque/mod.rs:939:9
     |
939  |         self.shrink_to(0);
939  |         self.shrink_to(0);
     |         ^^^^^^^^^^^^^^^^^
note: inside closure
    --> library/alloc/src/collections/vec_deque/tests.rs:838:48
     |
838  |     assert!(catch_unwind(AssertUnwindSafe(|| v.shrink_to_fit())).is_err());
     |                                                ^^^^^^^^^^^^^^^
     = note: inside `<{closure@library/alloc/src/collections/vec_deque/tests.rs:838:43: 838:45} as core::ops::FnOnce<()>>::call_once - shim` at /checkout/library/core/src/ops/function.rs:250:5: 250:71
     = note: inside `<core::panic::AssertUnwindSafe<{closure@library/alloc/src/collections/vec_deque/tests.rs:838:43: 838:45}> as core::ops::FnOnce<()>>::call_once` at /checkout/library/core/src/panic/unwind_safe.rs:272:9: 272:19
     = note: inside `std::panicking::r#try::do_call::<core::panic::AssertUnwindSafe<{closure@library/alloc/src/collections/vec_deque/tests.rs:838:43: 838:45}>, ()>` at /checkout/library/std/src/panicking.rs:552:40: 552:43
     = note: inside `std::panicking::r#try::<(), core::panic::AssertUnwindSafe<{closure@library/alloc/src/collections/vec_deque/tests.rs:838:43: 838:45}>>` at /checkout/library/std/src/panicking.rs:516:19: 516:88
     = note: inside `std::panic::catch_unwind::<core::panic::AssertUnwindSafe<{closure@library/alloc/src/collections/vec_deque/tests.rs:838:43: 838:45}>, ()>` at /checkout/library/std/src/panic.rs:149:14: 149:33
    --> library/alloc/src/collections/vec_deque/tests.rs:838:13
     |
     |
838  |     assert!(catch_unwind(AssertUnwindSafe(|| v.shrink_to_fit())).is_err());
note: inside closure
    --> library/alloc/src/collections/vec_deque/tests.rs:801:27
     |
800  | #[test]
---
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 1 previous error

error: test failed, to rerun pass `-p alloc --lib`
Caused by:
Caused by:
  process didn't exit successfully: `/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/cargo-miri runner /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/miri/x86_64-unknown-linux-gnu/debug/deps/alloc-156739569cd8cf42 -Z unstable-options --format json` (exit status: 1)
note: test exited abnormally; to see the full output pass --nocapture to the harness.
Build completed unsuccessfully in 0:04:44
make: *** [Makefile:54: check-aux] Error 1
  network time: Sun, 14 Apr 2024 07:00:02 GMT
##[error]Process completed with exit code 2.
Post job cleanup.

@bors
Copy link
Contributor

bors commented Apr 14, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 14, 2024
@matthiaskrgr matthiaskrgr deleted the rollup-8imjhnf branch September 1, 2024 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc O-unix Operating system: Unix-like rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.