Commit Graph

6419 Commits

Author SHA1 Message Date
Matthias Krüger
2ee3668ad5
Rollup merge of #127843 - workingjubilee:break-up-big-ass-stack-overflow-fn, r=joboet
unix: document unsafety for std `sig{action,altstack}`

I found many surprising elements here while trying to wrap a measly 5 functions with `unsafe`. I would rather not "just" mindlessly wrap this code with `unsafe { }`, so I decided to document it properly.

On Unix, this code covers the "create and setup signal handler" part of the stack overflow code, and serves as the primary safety boundary for the signal handler. It is rarely audited, very gnarly, and worth extra attention. It calls other unsafe functions defined in this module, but "can we correctly map the right memory, or find the right address ranges?" are separate questions, and get increasingly platform-specific. The question here is the more general "are we doing everything in the correct order, and setting up the handler in the correct way?"

As part of this audit, I noticed that we do some peculiar things that we should probably refrain from. However, I avoided making changes that I deemed might have a different final result in Rust programs. I did, however, reorder some events so that the signal handler is installed _after_ we install the alternate stack. We do not run much code between these events, but it is probably best if the timespan between the handler being available and the new stack being installed is 0 nanoseconds.
2024-07-20 13:24:53 +02:00
Chris Denton
c629bfc9e1
Inject win arm32 shims into metadata generation 2024-07-20 08:21:26 +00:00
Matthias Krüger
4da2869bc7
Rollup merge of #127918 - ChrisDenton:thread-name-string, r=joboet
Safely enforce thread name requirements

The requirements for the thread name to be both UTF-8 and null terminated are easily enforced by a wrapper type so lets do that. The fact this used to be just a bare `CString` has tripped me up before because it was entirely safe to use a non UTF-8 `CString`.
2024-07-20 07:13:43 +02:00
Matthias Krüger
bc86893a1a
Rollup merge of #123196 - Ayush1325:uefi-process, r=joboet
Add Process support for UEFI

UEFI does not have an actual process. However, it does provide methods to launch and execute another UEFI image. Having process support is important since it is possible to run rust test suit using `Command::output` and is the first step towards being able to run it for UEFI.

Here is an overview of how the support is implemented.

- We create a copy of the SystemTable. This is required since at least OVMF seems to crash if the original system table is modified.
- Stdout and Stderr pipe works by registering a new `simple_text_output` Protocol and pointing the child system table to use those.
- `Stdio::Inherit` just points the console to the current running image console which seems to work with even 3 levels of process.
- `spawn` is left unimplemented since it does not make sense for UEFI architecture. Additionally, since https://github.com/rust-lang/rust/pull/105458 was merged, the `spawn` and `output` implementations are completely independent.
2024-07-20 07:13:41 +02:00
Jubilee Young
e9b3e9c7f4 std: forbid unwrapped unsafe in unsupported_backslash 2024-07-19 13:46:06 -07:00
Jubilee Young
1d83da8847 kmc-solid: forbid(unsafe_op_in_unsafe_fn) 2024-07-19 13:46:06 -07:00
bors
ff4b39867e Auto merge of #127982 - matthiaskrgr:rollup-nzyvphj, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #127295 (CFI: Support provided methods on traits)
 - #127814 (`C-cmse-nonsecure-call`: improved error messages)
 - #127949 (fix: explain E0120 better cover cases when its raised)
 - #127966 (Use structured suggestions for unconstrained generic parameters on impl blocks)
 - #127976 (Lazy type aliases: Diagostics: Detect bivariant ty params that are only used recursively)
 - #127978 (Avoid ref when using format! for perf)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-19 18:40:33 +00:00
Matthias Krüger
e28be0d168
Rollup merge of #127978 - nyurik:lib-refs, r=workingjubilee
Avoid ref when using format! for perf

Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing).  Inlining format args prevents accidental `&` misuse.
2024-07-19 20:03:58 +02:00
Yuri Astrakhan
91275b2c2b Avoid ref when using format! for perf
Clean up a few minor refs in `format!` macro, as it has a tiny perf
cost. A few more minor related cleanups.
2024-07-19 12:23:49 -04:00
Matthias Krüger
45e4e96385
Rollup merge of #112328 - juliusl:pr/windows-add-change-time, r=ChrisDenton
Feat. adding ext that returns change_time

Addresses #112327
2024-07-19 17:06:49 +02:00
Ayush Singh
e2903989da
uefi: process: Fixes from PR
- Update system table crc32
- Fix unsound use of Box
- Free exit data
- Code improvements
- Introduce OwnedTable
- Update r-efi to latest version
- Use extended_varargs_abi_support for
  install_multiple_protocol_interfaces and
  uninstall_multiple_protocol_interfaces
- Fix comments
- Stub out args implementation

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19 17:44:27 +05:30
Ayush Singh
56e2a57505
uefi: process: Final Touchups
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19 17:43:45 +05:30
Ayush Singh
c899e05457
uefi: process: Add CommandArgs support
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19 17:43:45 +05:30
Ayush Singh
29c198c85f
uefi: process: Add support for args
Also fix stdio inherit

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19 17:43:45 +05:30
Ayush Singh
d44b3fb120
uefi: process Implement inherit
Only tested in 2 levels right now. Need args support for 3 levels

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19 17:43:45 +05:30
Ayush Singh
725376567a
uefi: process: Add null protocol
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19 17:43:45 +05:30
Ayush Singh
87d7a07f50
uefi: process: Add stderr support
Implement stderr support in similar fashion.

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19 17:43:44 +05:30
Ayush Singh
6737a02a50
uefi: process: Add support to capture stdout
Use a custom simple_text_output protocol to capture output.

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19 17:43:44 +05:30
Ayush Singh
a8d7121e4a
uefi: Add process
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19 17:43:37 +05:30
Nicholas Nethercote
c5dadd0408 Use #[rustfmt::skip] on some use groups to prevent reordering.
`use` declarations will be reformatted in #125443. Very rarely, there is
a desire to force a group of `use` declarations together in a way that
auto-formatting will break up. E.g. when you want a single comment to
apply to a group. #126776 dealt with all of these in the codebase,
ensuring that no comments intended for multiple `use` declarations would
end up in the wrong place. But some people were unhappy with it.

This commit uses `#[rustfmt::skip]` to create these custom `use` groups
in an idiomatic way for a few of the cases changed in #126776. This
works because rustfmt treats any `use` item annotated with
`#[rustfmt::skip]` as a barrier and won't reorder other `use` items
around it.
2024-07-19 13:26:48 +10:00
Jubilee
529fcbcd6d
unix: acquire-load NEED_ALTSTACK
Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2024-07-18 15:24:40 -07:00
Jubilee Young
c1740eee1e unix: Unsafe-wrap stack_overflow::{drop,make}_handler
Note that current_guard is probably not unsafe for future work.
2024-07-18 15:22:47 -07:00
Jubilee Young
fa628ceaff unix: Unsafe-wrap stack_overflow::cleanup
Editorialize on the wisdom of this as we do.
2024-07-18 15:22:17 -07:00
Jubilee Young
357ba1f8ec unix: lift init of sigaltstack before sigaction
This is technically "not necessary", as we will "just" segfault instead
if we e.g. arrive inside the handler fn with the null altstack. However,
it seems incorrect to go about this hoping that segfaulting is okay,
seeing as how our purpose here is to mitigate stack overflow problems.

Make sure NEED_ALTSTACK syncs with PAGE_SIZE when we do.

Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2024-07-18 15:18:38 -07:00
Jubilee Young
9e354daf7b unix: Unsafe-wrap stack_overflow::signal_handler
sometimes a safety comment is a prayer.
avoid fuzzy provenance casts after deref.

Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2024-07-18 15:12:18 -07:00
Chris Denton
9432955a01
Move ThreadName conversions to &cstr/&str 2024-07-18 19:53:09 +00:00
Chris Denton
8e4a9205e9
Style change 2024-07-18 18:10:36 +00:00
Chris Denton
939ee38304
Make Thread::new_inner a safe function 2024-07-18 17:33:52 +00:00
Matthias Krüger
f62aa415c3
Rollup merge of #124881 - Sp00ph:reentrant_lock_tid, r=joboet
Use ThreadId instead of TLS-address in `ReentrantLock`

Fixes #123458

`ReentrantLock` currently uses the address of a thread local variable as an ID that's unique across all currently running threads. This can lead to uninituitive behavior as in #123458 if TLS blocks get reused. This PR changes `ReentrantLock` to instead use the `ThreadId` provided by `std` as the unique ID. `ThreadId` guarantees uniqueness across the lifetime of the whole process, so we don't need to worry about reusing IDs of terminated threads. The main appeal of this PR is thus the possibility of changing the `ReentrantLock` API to guarantee that if a thread leaks a lock guard, no other thread may ever acquire that lock again.

This does entail some complications:
- previously, the only way to retrieve the current thread ID would've been using `thread::current().id()` which creates a temporary `Arc` and which isn't available in TLS destructors. As part of this PR, the thread ID instead gets cached in its own thread local, as suggested [here](https://github.com/rust-lang/rust/issues/123458#issuecomment-2038207704).
- `ThreadId` is always 64-bit whereas the current implementation uses a usize-sized ID. Since this ID needs to be updated atomically, we can't simply use a single atomic variable on 32 bit platforms. Instead, we fall back to using a (sound) seqlock on 32-bit platforms, which works because only one thread at a time can write to the ID. This seqlock is technically susceptible to the ABA problem, but the attack vector to create actual unsoundness has to be very specific:
  - You would need to be able to lock+unlock the lock exactly 2^31 times (or a multiple thereof) while a thread trying to lock it sleeps
  - The sleeping thread would have to suspend after reading one half of the thread id but before reading the other half
  - The teared result from combining the halves of the thread ID would have to exactly line up with the sleeping thread's ID

The risk of this occurring seems slim enough to be acceptable to me, but correct me if I'm wrong. This also means that the size of the lock increases by 8 bytes on 32-bit platforms, but this also shouldn't be an issue.

Performance wise, I did some crude testing of the only case where this could lead to real slowdowns, which is the case of locking a `ReentrantLock` that's already locked by the current thread. On both aarch64 and x86-64, there is (expectedly) pretty much no performance hit. I didn't have any 32-bit platforms to test the seqlock performance on, so I did the next best thing and just forced the 64-bit platforms to use the seqlock implementation. There, the performance degraded by ~1-2ns/(lock+unlock) on x86-64 and ~6-8ns/(lock+unlock) on aarch64, which is measurable but seems acceptable to me seeing as 32-bit platforms should be a small minority anyways.

cc `@joboet` `@RalfJung` `@CAD97`
2024-07-18 18:10:14 +02:00
Markus Everling
fe89962237 Update ReentrantLock implementation, add CURRENT_ID thread local.
This changes `ReentrantLock` to use `ThreadId` for the thread ownership check instead of the address of a thread local. Unlike TLS blocks, `ThreadId` is guaranteed to be unique across the lifetime of the process, so if any thread ever terminates while holding a `ReentrantLockGuard`, no other thread may ever acquire that lock again.

On platforms with 64-bit atomics, this is a very simple change. On other platforms, the approach used is slightly more involved, as explained in the module comment.

This also adds a `CURRENT_ID` thread local in addition to the already existing `CURRENT`. This allows us to access the current `ThreadId` without the relatively heavy machinery used by `thread::current().id()`.
2024-07-18 14:09:25 +00:00
Chris Denton
a605e2f498
Safely enforce thread name requirements 2024-07-18 13:45:20 +00:00
Matthias Krüger
3aafbd28e5
Rollup merge of #127077 - tbu-:pr_doc_fd_to_owned, r=workingjubilee
Make language around `ToOwned` for `BorrowedFd` more precise
2024-07-18 08:08:58 +02:00
Trevor Gross
8bb057874d
Rollup merge of #127861 - Kriskras99:patch-1, r=tgross35
Document the column numbers for the dbg! macro

The line numbers were also made consistent, some examples used the line numbers as shown on the playground while others used the line numbers that you would expect when just seeing the documentation.

The second option was chosen to make everything consistent.
2024-07-17 19:53:29 -05:00
Trevor Gross
3c4f820c5b
Rollup merge of #127845 - workingjubilee:actually-break-up-big-ass-stack-overflow-fn, r=joboet
unix: break `stack_overflow::install_main_guard` into smaller fn

This was one big deeply-indented function for no reason. This made it hard to reason about the boundaries of its safety. Or just, y'know, read. Simplify it by splitting it into platform-specific functions, but which are still asked to keep compiling (a desirable property, since all of these OS use a similar API).

This is mostly a whitespace change, so I suggest reviewing it only after setting Files changed -> (the options gear) -> [x] Hide whitespace as that will make it easier to see how the code was actually broken up instead of raw line diffs.
2024-07-17 19:53:28 -05:00
Julius Liu
35428cff60 feat: adding ext that returns change_time for Windows 2024-07-17 13:34:18 -07:00
bors
fcc325f1bc Auto merge of #125942 - timokroeger:windows-once-futex, r=ChrisDenton
Windows: Use futex implementation for `Once`

Keep the queue implementation for win7.
Inspired by PR #121956

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
2024-07-17 19:28:24 +00:00
Tobias Bucher
2162f3f34b Mention how you can go from BorrowedFd to OwnedFd and back 2024-07-17 14:34:00 +02:00
Tobias Bucher
538b31e977 Make language around ToOwned for BorrowedFd more precise 2024-07-17 14:33:39 +02:00
Kriskras99
99f879c32f
Document the column numbers for the dbg! macro
The line numbers were also made consistent, some examples used the line numbers as shown on the playground while others used the line numbers that you would expect when just seeing the documentation.
The second option was chosen to make everything consistent.
2024-07-17 14:10:41 +02:00
Trevor Gross
599d32414b
Rollup merge of #127813 - ChrisDenton:win-futex, r=joboet
Prevent double reference in generic futex

In the Windows futex implementation we were a little lax at allowing references to references (i.e. `&&`) which can lead to deadlocks due to reading the wrong memory address. This uses a trait to tighten the constraints and ensure this doesn't happen.

r? libs
2024-07-17 04:05:59 -05:00
Trevor Gross
56f95559da
Rollup merge of #127763 - ChrisDenton:safe-unsafe-unsafe, r=tgross35
Make more Windows functions `#![deny(unsafe_op_in_unsafe_fn)]`

As part of #127747, I've evaluated some more Windows functions and added `unsafe` blocks where necessary. Some are just trivial wrappers that "inherit" the full unsafety of their function, but for others I've added some safety comments. A few functions weren't actually unsafe at all. I think they were just using `unsafe fn` to avoid an `unsafe {}` block.

I'm not touching `c.rs` yet because that is partially being addressed by another PR and also I have plans to further reduce the number of wrapper functions we have in there.

r? libs
2024-07-17 04:05:59 -05:00
Jubilee Young
d47cb26ddd unix: unsafe-wrap install_main_guard_default 2024-07-17 00:08:05 -07:00
Jubilee Young
6ed563d491 unix: clean up install_main_guard_freebsd
This just was a mess.
2024-07-17 00:06:27 -07:00
Jubilee Young
e285c95cee unix: stack_start_aligned is a safe fn
This function is purely informative, answering where a stack starts.
This is a safe operation, even if an answer requires unsafe code,
and even if the result is some unsafe code decides to trust the answer.
It also doesn't need to fetch the PAGE_SIZE when its caller just did so!
Let's complicate its signature and in doing so simplify its operation.

This allows sprinkling around #[forbid(unsafe_op_in_unsafe_fn)]
2024-07-16 23:46:03 -07:00
Jubilee Young
17c70a9aac unix: split stack_overflow::install_main_guard by os 2024-07-16 23:32:02 -07:00
Chris Denton
0585c4a23e
Prevent double reference in generic futex 2024-07-17 05:57:39 +00:00
Chris Denton
2043de12a3
Narrow the scope of the ReadFile unsafe block 2024-07-17 05:53:20 +00:00
Chris Denton
a33abbba98
forbid(unsafe_op_in_unsafe_fn) in sys/os_str 2024-07-17 05:52:38 +00:00
Trevor Gross
1a1b44fcae
Rollup merge of #127836 - workingjubilee:forbid-unsafe-ops-in-xous-uefi, r=tgross35
std: Forbid unwrapped unsafe ops in xous and uefi modules
2024-07-16 20:10:14 -05:00
Trevor Gross
dd80a728cc
Rollup merge of #127833 - risc0:erik/zkvm-deny-unsafe, r=workingjubilee
zkvm: add `#[forbid(unsafe_op_in_unsafe_fn)]` in `stdlib`

This also adds an additional `unsafe` block to address compiler errors.
This PR is intended to address https://github.com/rust-lang/rust/issues/127747 for the zkvm target.
2024-07-16 20:10:13 -05:00
Trevor Gross
446e0177ec
Rollup merge of #127807 - ChrisDenton:win-parking, r=joboet
Use futex.rs for Windows thread parking

If I'm not overlooking anything then the Windows 10+ thread parking implementation is practically the same as the futex.rs implementation. So we may as well use the same implementation for both. The old version is still kept around for Windows 7 support.

r? ````@joboet```` if you wouldn't mind double checking I've not missed something
2024-07-16 20:10:12 -05:00
Trevor Gross
045b8107f2
Rollup merge of #127792 - workingjubilee:read-unaligned-is-dwarfier, r=joboet
std: Use `read_unaligned` for reads from DWARF

There's a lot of... *stuff* going on here. Meanwhile, `read_unaligned` has been available since 1.17.0, so let's just use that.
2024-07-16 20:10:12 -05:00
Trevor Gross
606d8cf9e8
Rollup merge of #126776 - nnethercote:rustfmt-use-pre-cleanups-2, r=cuviper
Clean up more comments near use declarations

#125443 will reformat all use declarations in the repository. There are a few edge cases involving comments on use declarations that require care. This PR fixes them up so #125443 can go ahead with a simple `x fmt --all`. A follow-up to #126717.

r? ``@cuviper``
2024-07-16 20:10:10 -05:00
Trevor Gross
689d27293a
Rollup merge of #125206 - mgeisler:simplify-std-env-vars, r=jhpratt,tgross35
Simplify environment variable examples

I’ve found myself visiting the documentation for `std::env::vars` every few months, and every time I do, it is because I want to quickly get a snippet to print out all environment variables :-)

So I think it could be nice to simplify the examples a little to make them self-contained. It is of course a style question if one should import a module a not, but I personally don’t import modules used just once in a code snippet.
2024-07-16 20:10:09 -05:00
Jubilee Young
586ef83f3f uefi: Forbid unwrapped unsafe in platform modules 2024-07-16 16:21:10 -07:00
Jubilee Young
b5a83a6f71 xous: Forbid unwrapped unsafe in platform modules 2024-07-16 16:16:03 -07:00
Erik Kaneda
e48d33e18a
zkvm: add #[forbid(unsafe_op_in_unsafe_fn)] in stdlib
This also adds an additional `unsafe` block to address compiler errors.
2024-07-16 16:04:02 -07:00
Nicholas Nethercote
75b6ec9800 Avoid comments that describe multiple use items.
There are some comments describing multiple subsequent `use` items. When
the big `use` reformatting happens some of these `use` items will be
reordered, possibly moving them away from the comment. With this
additional level of formatting it's not really feasible to have comments
of this type. This commit removes them in various ways:

- merging separate `use` items when appropriate;

- inserting blank lines between the comment and the first `use` item;

- outright deletion (for comments that are relatively low-value);

- adding a separate "top-level" comment.

We also entirely skip formatting for four library files that contain
nothing but `pub use` re-exports, where reordering would be painful.
2024-07-17 08:02:46 +10:00
Chris Denton
10b845cbc8
Add unsafe blocks in unsafe Thread::new 2024-07-16 20:48:39 +00:00
Chris Denton
55c84e39cc
Remove slice_to_end 2024-07-16 20:24:57 +00:00
Jubilee
249905780f
std: unwrapped unsafe is VERBOTEN!
Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2024-07-16 12:51:14 -07:00
Chris Denton
51bdcf66d3
Use futex.rs for Windows thread parking 2024-07-16 11:21:51 +00:00
Jubilee Young
8dafc5c819 std: Use read_unaligned for reading DWARF 2024-07-16 00:10:08 -07:00
袁浩----天命剑主
9183af25e5
deny unsafe_op_in_unsafe_fn for teeos 2024-07-16 11:47:22 +08:00
袁浩----天命剑主
af5c90d33f
clean unsafe op in unsafe fn 2024-07-16 11:46:16 +08:00
袁浩----天命剑主
00fff8ac64
clean unsafe op in unsafe fn 2024-07-16 11:34:23 +08:00
袁浩----天命剑主
060a40de63
clean unsafe op in unsafe fn 2024-07-16 11:18:51 +08:00
袁浩----天命剑主
00811621fe
delete #![allow(unsafe_op_in_unsafe_fn)]
this is redundant, so we can just delete it.
2024-07-16 11:05:18 +08:00
Pavel Grigorenko
f6fe7e49a2 lib: replace some mem::forget's with ManuallyDrop 2024-07-15 22:01:09 +03:00
bors
eb72697e41 Auto merge of #127020 - tgross35:f16-f128-classify, r=workingjubilee
Add classify and related methods for f16 and f128

Also constify some functions where that was blocked on classify being available.

r? libs
2024-07-15 17:20:33 +00:00
Chris Denton
5922234654
allow(unsafe_op_in_unsafe_fn) on some functions
These need to get their safety story straight
2024-07-15 14:16:17 +00:00
Chris Denton
37295e6268
Some Windows functions are safe 2024-07-15 14:16:17 +00:00
Chris Denton
d1a3c1daeb
Deny more windows unsafe_op_in_unsafe_fn 2024-07-15 14:16:11 +00:00
Chris Denton
fae6037884
Windows: move BSD socket shims to netc 2024-07-15 12:34:31 +00:00
Jubilee
476d399782
Rollup merge of #127750 - ChrisDenton:safe-unsafe-unsafe, r=workingjubilee
Make os/windows and pal/windows default to `#![deny(unsafe_op_in_unsafe_fn)]`

This is to prevent regressions in modules that currently pass. I did also fix up a few trivial places where the module contained only one or two simple wrappers. In more complex cases we should try to ensure the `unsafe` blocks are appropriately scoped and have any appropriate safety comments.

This does not fix the windows bits of #127747 but it should help prevent regressions until that is done and also make it more obvious specifically which modules need attention.
2024-07-15 02:28:44 -07:00
Jubilee
99c5302d9f
Rollup merge of #127744 - workingjubilee:deny-unsafe-op-in-std, r=jhpratt
std: `#![deny(unsafe_op_in_unsafe_fn)]` in platform-independent code

This applies the `unsafe_op_in_unsafe_fn` lint in all places in std that _do not have platform-specific cfg in their code_. For all such places, the lint remains allowed, because they need further work to address the relevant concerns. This list includes:

- `std::backtrace_rs` (internal-only)
- `std::sys` (internal-only)
- `std::os`

Notably this eliminates all "unwrapped" unsafe operations in `std::io` and `std::sync`, which will make them much more auditable in the future. Such has *also* been left for future work. While I made a few safety comments along the way on interfaces I have grown sufficiently familiar with, in most cases I had no context, nor particular confidence the unsafety was correct.

In the cases where I was able to determine the unsafety was correct without having prior context, it was obviously redundant. For example, an unsafe function calling another unsafe function that has the exact same contract, forwarding its caller's requirements just as it forwards its actual call.
2024-07-15 02:28:44 -07:00
Jubilee
64495b5f94
Rollup merge of #127712 - ChrisDenton:raw-types, r=workingjubilee
Windows: Remove some unnecessary type aliases

Back in the olden days, C did not have fixed-width types so these type aliases were at least potentially useful. Nowadays, and especially in Rust, we don't need the aliases and they don't help with anything. Notably the windows bindings we use also don't bother with the aliases. And even when we have used aliases they're often only used once then forgotten about.

The only one that gives me pause is `DWORD` because it's used a fair bit. But it's still used inconsistently and we implicitly assume it's a `u32` anyway (e.g. `as` casting from an `i32`).
2024-07-15 02:28:43 -07:00
Chris Denton
7e16d5fb61
Move safety comment outside unsafe block 2024-07-15 07:30:11 +00:00
Chris Denton
3411a025d5
Make os/windows default to deny unsafe in unsafe 2024-07-15 07:17:39 +00:00
Chris Denton
2402e84e78
Make pal/windows default to deny unsafe in unsafe 2024-07-15 07:00:40 +00:00
Chris Denton
816d90ae5f
Fix Windows 7 2024-07-15 06:14:53 +00:00
bors
0da95bd869 Auto merge of #127719 - devnexen:math_log_fix_solill, r=Amanieu
std: removes logarithms family function edge cases handling for solaris.

Issue had been fixed over time with solaris, 11.x behaves correctly
 (and we support it as minimum), illumos works correctly too.
2024-07-15 05:43:22 +00:00
Chris Denton
ffe8fc276e
Don't re-export c_int from c 2024-07-15 05:01:23 +00:00
Chris Denton
e2b062c9b5
Remove DWORD 2024-07-15 05:01:22 +00:00
Chris Denton
d8d7c5c3b9
Remove ULONG 2024-07-15 05:01:22 +00:00
Chris Denton
21f69b5b82
Remove PSRWLOCK 2024-07-15 05:01:22 +00:00
Chris Denton
84dd7e4959
Remove LPVOID 2024-07-15 05:01:21 +00:00
Chris Denton
351f1f36f6
Remove LPSECURITY_ATTRIBUTES 2024-07-15 05:01:21 +00:00
Chris Denton
1b7cf3a3f2
Remove LPOVERLAPPED 2024-07-15 05:01:21 +00:00
Chris Denton
8052fb8f3c
Remove LPCVOID 2024-07-15 05:01:21 +00:00
Chris Denton
286c3270b4
Remove SIZE_T 2024-07-15 05:01:20 +00:00
Chris Denton
5b700a76cf
Remove CHAR
As with USHORT, keep using C types for BSD socket APIs.
2024-07-15 05:01:20 +00:00
Chris Denton
f2cc94361c
Remove USHORT
We stick to C types in for socket and address as these are at least nominally BSD-ish and they're used outside of pal/windows in general *nix code
2024-07-15 05:01:20 +00:00
Chris Denton
e70cc28831
Remove LPWSTR 2024-07-15 05:01:20 +00:00
Chris Denton
b107cfa73c
Remove UINT 2024-07-15 05:01:19 +00:00
Chris Denton
65da4af0be
Remove LONG 2024-07-15 05:01:19 +00:00
Chris Denton
91ba4ebcfd
Remove LARGE_INTEGER 2024-07-15 05:01:19 +00:00
Chris Denton
1d1cae1ba5
Remove NonZeroDWORD 2024-07-15 05:01:18 +00:00
bors
594702ebb5 Auto merge of #127732 - GrigorenkoPV:teeos-safe-sys-init, r=Amanieu
sys::init is not unsafe on teeos

88fa119c77/library/std/src/sys/pal/teeos/mod.rs (L40-L42)

r​? `@petrochenkov`
2024-07-15 03:19:47 +00:00
Jubilee Young
e32460276c std: Unsafe-wrap std::sync 2024-07-14 17:59:37 -07:00
Jubilee Young
64fb2366da std: Unsafe-wrap in Wtf8 impl 2024-07-14 17:44:13 -07:00
Jubilee Young
df353a0cc3 std: Unsafe-wrap std::io 2024-07-14 17:17:55 -07:00
Jubilee Young
83a0fe5396 std: Directly call unsafe {un,}setenv in env 2024-07-14 17:08:44 -07:00
Jubilee Young
ce35265105 std: Unsafe-wrap OSStr{,ing}::from_encoded_bytes_unchecked 2024-07-14 16:59:12 -07:00
Jubilee Young
87d850dff0 std: Unsafe-wrap HashMap::get_many_unchecked_mut 2024-07-14 16:49:16 -07:00
Jubilee Young
4572ed6389 std: deny(unsafe_op_in_unsafe_fn) but allow sites
This provides a list of locations to hunt down issues in.
2024-07-14 16:44:01 -07:00
Trevor Gross
3a2c0aedf1 Add classify and related methods for f16 and f128 2024-07-14 18:44:43 -04:00
David Carlier
d939351c31
std: removes logarithms family function edge cases handling for solaris.
Issue had been fixed over time with solaris, 11.x behaves correctly
 (and we support it as minimum), illumos works correctly too.
2024-07-14 23:20:46 +01:00
Pavel Grigorenko
bbf303ed14 sys::init is not unsafe on teeos 2024-07-14 21:43:20 +03:00
bors
09682988f2 Auto merge of #125935 - madsmtm:merge-os-apple, r=workingjubilee
Merge Apple `std::os` extensions modules into `std::os::darwin`

The functionality available on Apple platforms are very similar, and were (basically) duplicated for each platform.

This PR rectifies that by merging the code into one module.

Ultimately, I've done this to fix `./x build library --target=aarch64-apple-tvos,aarch64-apple-watchos,aarch64-apple-visionos`, as that currently fails because of dead code warnings.

Publically exposing these to tvOS/watchOS/visionOS targets is considered in https://github.com/rust-lang/rust/pull/123723, but that seems to be dragging out, and in any case I think it makes sense to do the refactor separately from stabilization.

r? libs

Fixes https://github.com/rust-lang/rust/issues/121640 and https://github.com/rust-lang/rust/issues/124825.
2024-07-14 16:28:07 +00:00
Mads Marquart
306d5788a6 Merge Apple std::os extensions modules into std::os::darwin
The functionality available on Apple platforms are very similar, and
were duplicated for each platform.

Additionally, this fixes a warning when compiling the standard library
for tvOS, watchOS and visionOS by marking the corresponding code as
dead code.
2024-07-14 15:31:54 +02:00
Matthias Krüger
dba010d7fa
Rollup merge of #127704 - workingjubilee:fixup-better-than, r=ChrisDenton
Fix minor typos in std::process doc on Win argv
2024-07-14 10:05:21 +02:00
bors
8a63c84af5 Auto merge of #127706 - workingjubilee:rollup-d07ij30, r=workingjubilee
Rollup of 6 pull requests

Successful merges:

 - #122300 (Add FileCheck annotations to mir-opt/dest-prop tests)
 - #127434 (use "bootstrap" instead of "rustbuild" in comments and docs)
 - #127477 (Clear `inner_attr_ranges` regularly.)
 - #127558 (More attribute cleanups)
 - #127659 (Use ManuallyDrop in BufWriter::into_parts)
 - #127671 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 8))

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-14 05:41:24 +00:00
Jubilee
2d8493bb5f
Rollup merge of #127659 - saethlin:manually-drop-bufwriter, r=joboet
Use ManuallyDrop in BufWriter::into_parts

The fact that `mem::forget` takes by value means that it interacts very poorly with Stacked Borrows; generally users think of calling it as a no-op, but in Stacked Borrows, the field retagging tends to cause surprise tag invalidation.
2024-07-13 20:19:47 -07:00
Jubilee
285d45d299
Rollup merge of #127446 - zachs18:miri-stdlib-leaks-core-alloc, r=Mark-Simulacrum
Remove memory leaks in doctests in `core`, `alloc`, and `std`

cc `@RalfJung`  https://github.com/rust-lang/rust/issues/126067 https://github.com/rust-lang/miri/issues/3670

Should be no actual *documentation* changes[^1], all added/modified lines in the doctests are hidden with `#`,

This PR splits the existing memory leaks in doctests in `core`, `alloc`, and `std` into two general categories:

1. "Non-focused" memory leaks that are incidental to the thing being documented, and/or are easy to remove, i.e. they are only there because preventing the leak would make the doctest less clear and/or concise.
    - These doctests simply have a comment like `# // Prevent leaks for Miri.` above the added line that removes the memory leak.
    - [^2]Some of these would perhaps be better as part of the public documentation part of the doctest, to clarify that a memory leak can happen if it is not otherwise mentioned explicitly in the documentation  (specifically the ones in `(A)Rc::increment_strong_count(_in)`).
2. "Focused" memory leaks that are intentional and documented, and/or are possibly fragile to remove.
    - These doctests have a `# // FIXME` comment above the line that removes the memory leak, with a note that once `-Zmiri-disable-leak-check` can be applied at test granularity, these tests should be "un-unleakified" and have `-Zmiri-disable-leak-check` enabled.
    - Some of these are possibly fragile (e.g. unleaking the result of `Vec::leak`) and thus should definitely not be made part of the documentation.

This should be all of the leaks currently in `core` and `alloc`. I only found one leak in `std`, and it was in the first category (excluding the modules `@RalfJung` mentioned in https://github.com/rust-lang/rust/issues/126067 , and reducing the number of iterations of [one test](https://github.com/rust-lang/rust/blob/master/library/std/src/sync/once_lock.rs#L49-L94) from 1000 to 10)

[^1]: assuming [^2] is not added
[^2]: backlink
2024-07-13 20:18:23 -07:00
Jubilee
5c56577948
Rollup merge of #127370 - ChrisDenton:win-sys, r=Mark-Simulacrum
Windows: Add experimental support for linking std-required system DLLs using raw-dylib

For Windows, this allows std to define system imports without needing the user to have import libraries. It's intended for this to become the default.

For now it's an experimental feature so it can be tested using build-std.
2024-07-13 20:18:23 -07:00
Jubilee Young
99a5964b73 Fix minor typos in std::process doc on Win argv 2024-07-13 16:56:25 -07:00
David Carlier
6cd19116bc
std::unix::fs: removing, now useless, layers predating macOs 10.10.
fdopendir, openat and unlinkat are available since yosemite but we
support sierra as minimum.
2024-07-13 13:28:55 +01:00
bors
44fb8575de Auto merge of #127674 - jhpratt:rollup-0dxy3k7, r=jhpratt
Rollup of 3 pull requests

Successful merges:

 - #127654 (Fix incorrect NDEBUG handling in LLVM bindings)
 - #127661 (Stabilize io_slice_advance)
 - #127668 (Improved slice documentation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-13 06:05:25 +00:00
Jacob Pratt
68ec9c1992
Rollup merge of #127661 - eduardosm:stabilize-io_slice_advance, r=cuviper
Stabilize io_slice_advance

Closes https://github.com/rust-lang/rust/issues/62726 (FCP completed)

Stabilized API:

```rust
impl<'a> IoSlice<'a> {
    pub fn advance(&mut self, n: usize);
    pub fn advance_slices(bufs: &mut &mut [IoSlice<'a>], n: usize);
}

impl<'a> IoSliceMut<'a> {
    pub fn advance(&mut self, n: usize);
    pub fn advance_slices(bufs: &mut &mut [IoSliceMut<'a>], n: usize);
}
```
2024-07-13 00:24:35 -04:00
bors
0065384608 Auto merge of #127397 - jyn514:multi-thread-panic-hook, r=workingjubilee
fix interleaved output in the default panic hook when multiple threads panic simultaneously

previously, we only held a lock for printing the backtrace itself. since all threads were printing to the same file descriptor, that meant random output in the default panic hook from one thread would be interleaved with the backtrace from another. now, we hold the lock for the full duration of the hook, and the output is ordered.

---

i noticed some odd things while working on this you may or may not already be aware of.

- libbacktrace is included as a submodule instead of a normal rustc crate, and as a result uses `cfg(backtrace_in_std)` instead of a more normal `cfg(feature = "rustc-dep-of-std")`. probably this is left over from before rust used a cargo-based build system?
- the default panic handler uses `trace_unsynchronized`, etc, in `sys::backtrace::print`. as a result, the lock only applies to concurrent *panic handlers*, not concurrent *threads*.  in other words, if another, non-panicking, thread tried to print a backtrace at the same time as the panic handler, we may have UB, especially on windows.
    - we have the option of changing backtrace to enable locking when `backtrace_in_std` is set so we can reuse their lock instead of trying to add our own.
2024-07-13 03:42:24 +00:00
bors
03c2100ded Auto merge of #126606 - zachs18:patch-2, r=joboet
Guard against calling `libc::exit` multiple times on Linux.

Mitigates (but does not fix) #126600 by ensuring only one thread which calls Rust `exit` actually calls `libc::exit`, and all other callers of Rust `exit` block.
2024-07-13 01:18:59 +00:00
Ben Kimock
7fc69436a1 Use ManuallyDrop in BufWriter::into_parts 2024-07-12 17:15:50 -04:00
Eduardo Sánchez Muñoz
a45c12cf0f Stabilize io_slice_advance 2024-07-12 20:09:29 +02:00
jyn
1c8f9bb84d fix interleaved panic output
previously, we only held a lock for printing the backtrace itself. since all threads were printing to the same file descriptor, that meant random output in the default panic hook would be interleaved with the backtrace. now, we hold the lock for the full duration of the hook, and the output is ordered.
2024-07-12 11:52:04 -04:00
Matthias Krüger
f9b3e8b387
Rollup merge of #126827 - the8472:pidfd-spawn, r=workingjubilee
Use pidfd_spawn for faster process spawning when a PidFd is requested

glibc 2.39 added `pidfd_spawnp` and `pidfd_getpid` which makes it possible to get pidfds while staying on the CLONE_VFORK path.

verified that vfork gets used with strace:

```
$  strace -ff -e pidfd_open,clone3,openat,execve,waitid,close ./x test std --no-doc -- pidfd
[...]
[pid 2820532] clone3({flags=CLONE_VM|CLONE_PIDFD|CLONE_VFORK|CLONE_CLEAR_SIGHAND, pidfd=0x7b7f885fec6c, exit_signal=SIGCHLD, stack=0x7b7f88aff000, stack_size=0x9000}strace: Process 2820533 attached
 <unfinished ...>
[pid 2820533] execve("/home/the8472/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory)
[pid 2820533] execve("/home/the8472/.cargo/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory)
[pid 2820533] execve("/usr/local/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory)
[pid 2820533] execve("/usr/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */ <unfinished ...>
[pid 2820532] <... clone3 resumed> => {pidfd=[3]}, 88) = 2820533
[pid 2820533] <... execve resumed>)     = 0
[pid 2820532] openat(AT_FDCWD, "/proc/self/fdinfo/3", O_RDONLY|O_CLOEXEC) = 4
[pid 2820532] close(4)                  = 0
```

Tracking issue: #82971
2024-07-12 14:37:58 +02:00
Matthias Krüger
47ab86653e
Rollup merge of #127599 - tgross35:lazy_cell_consume-rename, r=workingjubilee
Rename `lazy_cell_consume` to `lazy_cell_into_inner`

Name this something that is less confusable with an atomic consume API for `{Lazy,Once}Lock`.
2024-07-11 17:01:39 +02:00
Trevor Gross
ab56fe2053 Rename lazy_cell_consume to lazy_cell_into_inner
Name this something that is less confusable with an atomic consume API for
`{Lazy,Once}Lock`.
2024-07-11 03:16:45 -04:00
Zachary S
84d84daf17 Explicitly ignore into_raw_handle() using let _ = in sys/pal/windows. 2024-07-10 21:03:25 -05:00
Zachary S
6d477d3a9d Add must_use to IntoRawFd/IntoRawSocket/IntoRawHandle's methods. 2024-07-10 13:08:24 -05:00
Tobias Bucher
45ad522e87 Don't mark DEBUG_EVENT struct as repr(packed)
That would give it alignment of 1 which is ABI-incompatible with its C
definition.
2024-07-10 15:47:24 +02:00
Andres Olivares
b8b6d14de9 Fixed doc links 2024-07-09 22:09:13 -04:00
Andres Olivares
e82ad2e622 Few changes to doc comments. Added tracking issue number. 2024-07-09 22:09:13 -04:00
Andres Olivares
06d76c3156 Exposing STARTUPINFOW.wShowWindow in CommandExt (show_window function) to control how a new process should display its window (normal, minimized, maximized, etc) 2024-07-09 22:09:13 -04:00
bors
32e692681e Auto merge of #127235 - martn3:no-mips-f16, r=tgross35,scottmcm
std: Set `has_reliable_f16` to false for MIPS targets in build.rs

This PR makes std tests link for MIPS again (they broke with https://github.com/rust-lang/rust/pull/126608) by avoiding the following link errors. Step-by-step instructions on how to reproduce these errors in docker can be found below.

    std.9e27ea-cgu.12:(.text._ZN3std3num8test_num17edc3E+0x38): undefined reference to `__gnu_f2h_ieee'
    std.9e27ea-cgu.12:(.text._ZN3std3num8test_num17hdc3E+0x38): undefined reference to `__gnu_h2f_ieee'

This PR just adds one line of config in existing f16 infrastructure. It also disables four doctests that fails with the same link errors.

## Step-by-step to reproduce linking error

1. Prepare:

```sh
docker run -it ubuntu:24.10

apt update && apt install -y \
    libc6-mips-cross \
    libc6-mipsel-cross \
    libc6-mips64-cross \
    libc6-mips64el-cross \
    gcc-mips-linux-gnu \
    gcc-mipsel-linux-gnu \
    gcc-mips64-linux-gnuabi64 \
    gcc-mips64el-linux-gnuabi64 \
    git curl python3 build-essential

git clone --depth 1 https://github.com/rust-lang/rust.git
cd rust
```
2. Try to link std tests for any of these 4 MIPS targets by running any one of these commands:

```sh
CC_mips_unknown_linux_gnu=mips-linux-gnu-gcc \
CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \
./x test library/std --target mips-unknown-linux-gnu

CC_mipsel_unknown_linux_gnu=mipsel-linux-gnu-gcc \
CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER=mipsel-linux-gnu-gcc \
./x test library/std --target mipsel-unknown-linux-gnu

CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc \
CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \
./x test library/std --target mips64-unknown-linux-gnuabi64

CC_mips64el_unknown_linux_gnuabi64=mips64el-linux-gnuabi64-gcc \
CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \
./x test library/std --target mips64el-unknown-linux-gnuabi64
```

### Expected

No link error. After this PR there are no link errors.

### Actual

```
error: linking with `mips-linux-gnu-gcc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin:/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin:/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "mips-linux-gnu-gcc" "/tmp/rustcEtKsay/symbols.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.00.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.01.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.02.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.03.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.04.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.05.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.06.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.07.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.08.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.09.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.10.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.11.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.12.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.13.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.14.rcgu.o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.15.rcgu.o" "-Wl,--as-needed" "-L" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps" "-L" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/release/deps" "-L" "/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/mips-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/librand_xorshift-deb32232a867c543.rlib" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/librand-5a391600dce9d98f.rlib" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/librand_core-a11cfba3d86c5298.rlib" "/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/mips-unknown-linux-gnu/lib/libtest-65b05caf5a9b99a4.rlib" "/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/mips-unknown-linux-gnu/lib/libgetopts-ba692b2f798aef60.rlib" "/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/mips-unknown-linux-gnu/lib/libunicode_width-20ec8b475126cb0b.rlib" "/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/mips-unknown-linux-gnu/lib/librustc_std_workspace_std-c17f739fee51cc86.rlib" "-L" "/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/mips-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-lstd-124ee57a4c00deda" "-Wl,-Bstatic" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/libcompiler_builtins-bd55a137b89bc81f.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/mips-unknown-linux-gnu/lib" "-o" "/rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "-Wl,-z,origin" "-Wl,-rpath,$ORIGIN/../lib"
  = note: /usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /rust/build/x86_64-unknown-linux-gnu/stage1-std/mips-unknown-linux-gnu/release/deps/std-1cffa50fa8c43b63.std.9ee227e919a554fa-cgu.12.rcgu.o: in function `std::num::test_num':
          std.9ee227e919a554fa-cgu.12:(.text._ZN3std3num8test_num17haed2ea710c1afdc3E+0x38): undefined reference to `__gnu_f2h_ieee'
          /usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: std.9ee227e919a554fa-cgu.12:(.text._ZN3std3num8test_num17haed2ea710c1afdc3E+0x3c): undefined reference to `__gnu_f2h_ieee'
          /usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: std.9ee227e919a554fa-cgu.12:(.text._ZN3std3num8test_num17haed2ea710c1afdc3E+0x44): undefined reference to `__gnu_h2f_ieee'
          ...
          collect2: error: ld returned 1 exit status

error: could not compile `std` (lib test) due to 1 previous error
```
2024-07-08 18:22:26 +00:00
Matthias Krüger
55d25ceccb
Rollup merge of #127460 - Borgerr:clarify-drop-comment, r=jhpratt
clarify `sys::unix::fd::FileDesc::drop` comment

closes #66876

simply clarifies some resource-relevant things regarding the `close` syscall to reduce the amount of search needed in other parts of the web.
2024-07-08 16:28:17 +02:00
zachs18
8bcbab5dd1
Attempt to fix CI 2024-07-08 09:19:25 -05:00
B I Mohammed Abbas
6519c143a7 Reset sigpipe not supported for vxworks 2024-07-08 10:56:13 +05:30
zachs18
98010765f9
Move/change declaration of mod exit_guard; 2024-07-07 10:44:47 -05:00
Ashton Hunt
a0f2b41d03 clarify sys::unix::fd::FileDesc::drop comment (#66876) 2024-07-07 09:29:16 -06:00
Matthias Krüger
b564c510c1
Rollup merge of #127447 - RalfJung:once_lock_miri, r=joboet
once_lock: make test not take as long in Miri

Allocating 1000 list elements takes a while (`@zachs18` reported >5min), so let's reduce the iteration count when running in Miri. Unfortunately due to this clever `while let i @ 0..LEN =` thing, the count needs to be a constants, and constants cannot be shadowed, so we need to use another trick to hide the `cfg!(miri)` from the docs. (I think this loop condition may be a bit too clever, it took me a bit to decipher. Ideally this would be `while let i = ... && i < LEN`, but that is not stable yet.)
2024-07-07 14:22:03 +02:00
Matthias Krüger
56557c4555
Rollup merge of #127297 - the8472:path-new-hash, r=Nilstrieb
Improve std::Path's Hash quality by avoiding prefix collisions

This adds a bit rotation to the already existing state so that the same sequence of characters chunked at different offsets into separate path components results in different hashes.

The tests are from #127255

Closes #127254
2024-07-07 14:22:00 +02:00
Ralf Jung
bee9120458 once_lock: make test not take as long in Miri 2024-07-07 09:19:32 +02:00
Zachary S
a10c7a4b9b Remove non-focused memory leak in std doctest for Miri. 2024-07-06 23:35:31 -05:00
Michael Goulet
f20307851e
Rollup merge of #123600 - tisonkun:path_with_extension, r=dtolnay
impl PathBuf::add_extension and Path::with_added_extension

See the ACP for motivation and discussions - https://github.com/rust-lang/libs-team/issues/368
2024-07-05 20:49:31 -04:00
Zachary S
5db165504a Attempt to fix CI 2024-07-05 17:59:46 -05:00
Zachary S
a609370143 Move exit guard from sys::common::exit_guard to sys::exit_guard. 2024-07-05 17:01:08 -05:00
zachs18
9de76e3201
Update library/std/src/sys/pal/common/exit_guard.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2024-07-05 16:45:03 -05:00
tison
3aa2abdd3d
add unit tests for extra extension feature
Signed-off-by: tison <wander4096@gmail.com>
2024-07-05 10:44:15 -07:00
tison
a0f4114ba9
update comments
Signed-off-by: tison <wander4096@gmail.com>
2024-07-05 10:29:35 -07:00