about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2024-07-12fix interleaved panic outputjyn-30/+31
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-12Rollup merge of #126827 - the8472:pidfd-spawn, r=workingjubileeMatthias Krüger-6/+131
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-11[library/std/src/process.rs] `PartialEq` & `Eq` for `ExitCode`Samuel Marks-1/+1
2024-07-11Rollup merge of #127599 - tgross35:lazy_cell_consume-rename, r=workingjubileeMatthias Krüger-2/+2
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-11Rename `lazy_cell_consume` to `lazy_cell_into_inner`Trevor Gross-2/+2
Name this something that is less confusable with an atomic consume API for `{Lazy,Once}Lock`.
2024-07-10Explicitly ignore `into_raw_handle()` using `let _ =` in sys/pal/windows.Zachary S-3/+3
2024-07-10Add `must_use` to IntoRawFd/IntoRawSocket/IntoRawHandle's methods.Zachary S-0/+4
2024-07-10Don't mark `DEBUG_EVENT` struct as `repr(packed)`Tobias Bucher-1/+1
That would give it alignment of 1 which is ABI-incompatible with its C definition.
2024-07-09Fixed doc linksAndres Olivares-2/+2
2024-07-09Few changes to doc comments. Added tracking issue number.Andres Olivares-4/+5
2024-07-09Exposing STARTUPINFOW.wShowWindow in CommandExt (show_window function) to ↵Andres Olivares-0/+22
control how a new process should display its window (normal, minimized, maximized, etc)
2024-07-08Rollup merge of #127460 - Borgerr:clarify-drop-comment, r=jhprattMatthias Krüger-0/+5
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-08Attempt to fix CIzachs18-3/+12
2024-07-08Reset sigpipe not supported for vxworksB I Mohammed Abbas-0/+1
2024-07-07Move/change declaration of `mod exit_guard;`zachs18-1/+1
2024-07-07clarify `sys::unix::fd::FileDesc::drop` comment (#66876)Ashton Hunt-0/+5
2024-07-07Rollup merge of #127447 - RalfJung:once_lock_miri, r=joboetMatthias Krüger-6/+13
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-07Rollup merge of #127297 - the8472:path-new-hash, r=NilstriebMatthias Krüger-4/+44
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-07once_lock: make test not take as long in MiriRalf Jung-6/+13
2024-07-06Remove non-focused memory leak in `std` doctest for Miri.Zachary S-0/+3
2024-07-05Rollup merge of #123600 - tisonkun:path_with_extension, r=dtolnayMichael Goulet-0/+168
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-05Attempt to fix CIZachary S-0/+2
2024-07-05Move exit guard from sys::common::exit_guard to sys::exit_guard.Zachary S-4/+3
2024-07-05Update library/std/src/sys/pal/common/exit_guard.rszachs18-3/+5
Co-authored-by: Ralf Jung <post@ralfj.de>
2024-07-05add unit tests for extra extension featuretison-0/+74
Signed-off-by: tison <wander4096@gmail.com>
2024-07-05update commentstison-4/+1
Signed-off-by: tison <wander4096@gmail.com>
2024-07-05Add experimental raw-dylib feature to stdChris Denton-0/+13
For Windows, this allows defining imports without needing the user to have import libraries. It's intended for this to become the default.
2024-07-05Use windows_targets macro for allocChris Denton-67/+64
2024-07-05Rollup merge of #127320 - ChrisDenton:win-sys, r=Mark-SimulacrumGuillaume Gomez-851/+162
Update windows-bindgen to 0.58.0 This also switches from the bespoke `std` generated bindings to the normal `sys` ones everyone else uses. This has almost no difference except that the `sys` bindings use the `windows_targets::links!` macro for FFI imports, which we implement manually. This does cause the diff to look much larger than it really is but the bulk of the changes are mostly contained to the generated code.
2024-07-04Add comments to windows_targets.rsChris Denton-0/+9
2024-07-04Update windows-bindgen to 0.58.0Chris Denton-851/+153
2024-07-04Rollup merge of #127195 - biabbas:vxworks_cleanup, r=jhprattJacob Pratt-2/+4
Remove unqualified form import of io::Error in process_vxworks.rs and fallback on remove_dir_impl for vxworks Hi all, This is to address issue #127084. On inspections it was found that io::Error refrences were all of qualified form and there was no need to add a unqualified form import. Also to successfully build rust for vxworks, we need to fallback on the remove_impl_dir implementations. Thank you.
2024-07-04Rollup merge of #126792 - wooden-worm:master, r=Mark-SimulacrumJacob Pratt-10/+16
wasm64 build with target-feature=+simd128,+atomics Fixes https://github.com/rust-lang/rust/issues/126778
2024-07-03impl PathBuf::add_extension and Path::with_added_extensiontison-0/+97
Signed-off-by: tison <wander4096@gmail.com>
2024-07-04stir the hash state a little to avoid prefix collisionsThe 8472-4/+9
2024-07-03Add more test cases for path comparisonsZanie Blue-0/+28
2024-07-03Add test case demonstrating equality of paths "foo/bar" and "foobar"Zanie Blue-0/+7
2024-07-03Move unique_thread_exit call to lang_start_internal so it is not in a ↵Zachary S-3/+4
generic function, and wrap it in `catch_unwind`
2024-07-03Remove Miri special-caseZachary S-9/+1
2024-07-03Use pthread_t instead of numeric thread idZachary S-45/+12
2024-07-03Use libc::pause instead of std::thread::park in wait-for-exit loopZachary S-7/+10
2024-07-03Rollup merge of #123588 - tgross35:stabilize-assert_unchecked, r=dtolnayJacob Pratt-1/+0
Stabilize `hint::assert_unchecked` Make the following API stable, including const: ```rust // core::hint, std::hint pub const unsafe fn assert_unchecked(p: bool); ``` This PR also reworks some of the documentation and adds an example. Tracking issue: https://github.com/rust-lang/rust/issues/119131 FCP: https://github.com/rust-lang/rust/issues/119131#issuecomment-1906394087. The docs update should resolve the remaining concern.
2024-07-03Fall back on remove dir implementation for vxworksB I Mohammed Abbas-1/+3
2024-07-02Rollup merge of #127230 - hattizai:patch01, r=saethlinMatthias Krüger-3/+3
chore: remove duplicate words remove duplicate words in comments to improve readability.
2024-07-02chore: remove duplicate wordshattizai-3/+3
2024-07-01Rollup merge of #126732 - StackOverflowExcept1on:master, r=m-ou-seGuillaume Gomez-1/+0
Stabilize `PanicInfo::message()` and `PanicMessage` Resolves #66745 This stabilizes the [`PanicInfo::message()`](https://doc.rust-lang.org/nightly/core/panic/struct.PanicInfo.html#method.message) and [`PanicMessage`](https://doc.rust-lang.org/nightly/core/panic/struct.PanicMessage.html). Demonstration of [custom panic handler](https://github.com/StackOverflowExcept1on/panicker): ```rust #![no_std] #![no_main] extern crate libc; #[no_mangle] extern "C" fn main() -> libc::c_int { panic!("I just panic every time"); } #[panic_handler] fn my_panic(panic_info: &core::panic::PanicInfo) -> ! { use arrayvec::ArrayString; use core::fmt::Write; let message = panic_info.message(); let location = panic_info.location().unwrap(); let mut debug_msg = ArrayString::<1024>::new(); let _ = write!(&mut debug_msg, "panicked with '{message}' at '{location}'"); if debug_msg.try_push_str("\0").is_ok() { unsafe { libc::puts(debug_msg.as_ptr() as *const _); } } unsafe { libc::exit(libc::EXIT_FAILURE) } } ``` ``` $ cargo +stage1 run --release panicked with 'I just panic every time' at 'src/main.rs:8:5' ``` - [x] FCP: https://github.com/rust-lang/rust/issues/66745#issuecomment-2198143725 r? libs-api
2024-07-01Remove unqualified import io:: Error for vxworks as all Error references are ↵B I Mohammed Abbas-1/+1
qualified in process_vxworks.rs
2024-06-29Rollup merge of #126953 - joboet:lazy_key, r=jhprattMatthias Krüger-128/+115
std: separate TLS key creation from TLS access Currently, `std` performs an atomic load to get the OS key on every access to `StaticKey` even when the key is already known. This PR thus replaces `StaticKey` with the platform-specific `get` and `set` function and a new `LazyKey` type that acts as a `LazyLock<Key>`, allowing the reuse of the retreived key for multiple accesses. Related to #110897.
2024-06-28std: add safety commentsjoboet-4/+16
2024-06-27Rollup merge of #126980 - Borgerr:fix-extendfromslice-check, r=workingjubileeJacob Pratt-1/+25
set self.is_known_utf8 to false in extend_from_slice try-job: x86_64-msvc closes #126977 Related to #126885, #126333, and [this conversation](<https://github.com/rust-lang/rust/commit/aa46a3368eb017eba41bfab956c7787d46c09935#r143539097>)