about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2024-03-11 03:47:20 -0400
committerGitHub <noreply@github.com>2024-03-11 03:47:20 -0400
commitb3ac6fab3d98bc5d638da2c284f9bf623b87862f (patch)
tree1777379b0a9b496d3642ae6f5b61caf28df24987
parent100985989961589c9b3ea8950d36dd1e7ab7fb93 (diff)
parentffdd97f79178f16c5306a84af933aa31f223ffb4 (diff)
downloadrust-b3ac6fab3d98bc5d638da2c284f9bf623b87862f.tar.gz
rust-b3ac6fab3d98bc5d638da2c284f9bf623b87862f.zip
Rollup merge of #122002 - devnexen:thread_stack_netbsd_fix, r=workingjubilee,riastradh
std::threads: revisit stack address calculation on netbsd.

like older linux glibc versions, we need to get the guard size
 and increasing the stack's bottom address accordingly.
-rw-r--r--library/std/src/sys/pal/unix/thread.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs
index 2af6382f3da..6520ca9fc48 100644
--- a/library/std/src/sys/pal/unix/thread.rs
+++ b/library/std/src/sys/pal/unix/thread.rs
@@ -806,9 +806,9 @@ pub mod guard {
     #[cfg(any(
         target_os = "android",
         target_os = "freebsd",
+        target_os = "netbsd",
         target_os = "hurd",
         target_os = "linux",
-        target_os = "netbsd",
         target_os = "l4re"
     ))]
     unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
@@ -911,9 +911,10 @@ pub mod guard {
                         }
                     }) * page_size;
             Some(guard)
-        } else if cfg!(target_os = "openbsd") {
+        } else if cfg!(any(target_os = "openbsd", target_os = "netbsd")) {
             // OpenBSD stack already includes a guard page, and stack is
             // immutable.
+            // NetBSD stack includes the guard page.
             //
             // We'll just note where we expect rlimit to start
             // faulting, so our handler can report "stack overflow", and