about summary refs log tree commit diff
path: root/library/std/src/sys/sync/rwlock/queue.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-04-14 09:01:58 +0200
committerGitHub <noreply@github.com>2024-04-14 09:01:58 +0200
commit2ba0c627dee4dc32b451e542c7b274e382a781a0 (patch)
treed7452fd5d6fdf323db73684e036ae6aa3425b654 /library/std/src/sys/sync/rwlock/queue.rs
parent2bec57d4a9405b256ec10d524fd917823a68049d (diff)
parent126c762b8577dc65ccba1e0105d5c153bcc1ad56 (diff)
Rollup merge of #123879 - beetrees:missing-unsafe, r=Mark-Simulacrum
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 #123505 has been merged.
Diffstat (limited to 'library/std/src/sys/sync/rwlock/queue.rs')
-rw-r--r--library/std/src/sys/sync/rwlock/queue.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/std/src/sys/sync/rwlock/queue.rs b/library/std/src/sys/sync/rwlock/queue.rs
index d1918855797..337cc6c2ca0 100644
--- a/library/std/src/sys/sync/rwlock/queue.rs
+++ b/library/std/src/sys/sync/rwlock/queue.rs
@@ -202,7 +202,7 @@ impl Node {
     fn prepare(&mut self) {
         // Fall back to creating an unnamed `Thread` handle to allow locking in
         // TLS destructors.
-        self.thread.get_or_init(|| thread::try_current().unwrap_or_else(|| Thread::new(None)));
+        self.thread.get_or_init(|| thread::try_current().unwrap_or_else(Thread::new_unnamed));
         self.completed = AtomicBool::new(false);
     }