2015-01-29 07:19:28 +00:00
|
|
|
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
|
2014-11-24 03:21:17 +00:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2015-04-15 05:13:57 +00:00
|
|
|
use alloc::boxed::FnBox;
|
2014-11-24 03:21:17 +00:00
|
|
|
use cmp;
|
2016-03-25 04:46:45 +00:00
|
|
|
use ffi::CStr;
|
2015-03-13 03:21:17 +00:00
|
|
|
use io;
|
|
|
|
use libc;
|
2014-11-24 03:21:17 +00:00
|
|
|
use mem;
|
|
|
|
use ptr;
|
2015-03-13 03:21:17 +00:00
|
|
|
use sys::os;
|
|
|
|
use time::Duration;
|
2014-11-24 03:21:17 +00:00
|
|
|
|
|
|
|
use sys_common::thread::*;
|
|
|
|
|
2017-09-09 09:09:34 +00:00
|
|
|
#[cfg(not(target_os = "l4re"))]
|
|
|
|
pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
|
|
|
|
#[cfg(target_os = "l4re")]
|
|
|
|
pub const DEFAULT_MIN_STACK_SIZE: usize = 1024 * 1024;
|
|
|
|
|
2015-04-15 05:13:57 +00:00
|
|
|
pub struct Thread {
|
|
|
|
id: libc::pthread_t,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Some platforms may have pthread_t as a pointer in which case we still want
|
|
|
|
// a thread to be Send/Sync
|
|
|
|
unsafe impl Send for Thread {}
|
|
|
|
unsafe impl Sync for Thread {}
|
|
|
|
|
2016-09-25 20:47:00 +00:00
|
|
|
// The pthread_attr_setstacksize symbol doesn't exist in the emscripten libc,
|
|
|
|
// so we have to not link to it to satisfy emcc's ERROR_ON_UNDEFINED_SYMBOLS.
|
|
|
|
#[cfg(not(target_os = "emscripten"))]
|
|
|
|
unsafe fn pthread_attr_setstacksize(attr: *mut libc::pthread_attr_t,
|
|
|
|
stack_size: libc::size_t) -> libc::c_int {
|
|
|
|
libc::pthread_attr_setstacksize(attr, stack_size)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_os = "emscripten")]
|
|
|
|
unsafe fn pthread_attr_setstacksize(_attr: *mut libc::pthread_attr_t,
|
|
|
|
_stack_size: libc::size_t) -> libc::c_int {
|
|
|
|
panic!()
|
|
|
|
}
|
|
|
|
|
2015-04-15 05:13:57 +00:00
|
|
|
impl Thread {
|
|
|
|
pub unsafe fn new<'a>(stack: usize, p: Box<FnBox() + 'a>)
|
|
|
|
-> io::Result<Thread> {
|
|
|
|
let p = box p;
|
|
|
|
let mut native: libc::pthread_t = mem::zeroed();
|
|
|
|
let mut attr: libc::pthread_attr_t = mem::zeroed();
|
2015-11-03 00:23:22 +00:00
|
|
|
assert_eq!(libc::pthread_attr_init(&mut attr), 0);
|
2015-04-15 05:13:57 +00:00
|
|
|
|
2015-07-27 20:41:35 +00:00
|
|
|
let stack_size = cmp::max(stack, min_stack_size(&attr));
|
2017-08-18 09:50:20 +00:00
|
|
|
|
2016-09-25 20:47:00 +00:00
|
|
|
match pthread_attr_setstacksize(&mut attr,
|
2016-10-08 13:48:28 +00:00
|
|
|
stack_size) {
|
2015-04-15 05:13:57 +00:00
|
|
|
0 => {}
|
|
|
|
n => {
|
|
|
|
assert_eq!(n, libc::EINVAL);
|
|
|
|
// EINVAL means |stack_size| is either too small or not a
|
|
|
|
// multiple of the system page size. Because it's definitely
|
|
|
|
// >= PTHREAD_STACK_MIN, it must be an alignment issue.
|
|
|
|
// Round up to the nearest page and try again.
|
|
|
|
let page_size = os::page_size();
|
|
|
|
let stack_size = (stack_size + page_size - 1) &
|
|
|
|
(-(page_size as isize - 1) as usize - 1);
|
2015-11-03 00:23:22 +00:00
|
|
|
assert_eq!(libc::pthread_attr_setstacksize(&mut attr,
|
|
|
|
stack_size), 0);
|
2015-04-15 05:13:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-11-03 00:23:22 +00:00
|
|
|
let ret = libc::pthread_create(&mut native, &attr, thread_start,
|
|
|
|
&*p as *const _ as *mut _);
|
|
|
|
assert_eq!(libc::pthread_attr_destroy(&mut attr), 0);
|
2015-04-15 05:13:57 +00:00
|
|
|
|
|
|
|
return if ret != 0 {
|
|
|
|
Err(io::Error::from_raw_os_error(ret))
|
|
|
|
} else {
|
|
|
|
mem::forget(p); // ownership passed to pthread_create
|
|
|
|
Ok(Thread { id: native })
|
|
|
|
};
|
|
|
|
|
|
|
|
extern fn thread_start(main: *mut libc::c_void) -> *mut libc::c_void {
|
2017-11-01 20:04:03 +00:00
|
|
|
unsafe { start_thread(main as *mut u8); }
|
2015-09-03 06:49:50 +00:00
|
|
|
ptr::null_mut()
|
2015-04-15 05:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn yield_now() {
|
2015-11-03 00:23:22 +00:00
|
|
|
let ret = unsafe { libc::sched_yield() };
|
2015-04-15 05:13:57 +00:00
|
|
|
debug_assert_eq!(ret, 0);
|
|
|
|
}
|
|
|
|
|
2015-11-26 19:05:10 +00:00
|
|
|
#[cfg(any(target_os = "linux",
|
2016-08-08 23:41:51 +00:00
|
|
|
target_os = "android"))]
|
2016-03-25 04:46:45 +00:00
|
|
|
pub fn set_name(name: &CStr) {
|
2015-04-15 05:13:57 +00:00
|
|
|
const PR_SET_NAME: libc::c_int = 15;
|
2015-11-03 00:23:22 +00:00
|
|
|
// pthread wrapper only appeared in glibc 2.12, so we use syscall
|
|
|
|
// directly.
|
2015-04-15 05:13:57 +00:00
|
|
|
unsafe {
|
2016-03-25 04:46:45 +00:00
|
|
|
libc::prctl(PR_SET_NAME, name.as_ptr() as libc::c_ulong, 0, 0, 0);
|
2015-04-15 05:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(target_os = "freebsd",
|
|
|
|
target_os = "dragonfly",
|
|
|
|
target_os = "bitrig",
|
|
|
|
target_os = "openbsd"))]
|
2016-03-25 04:46:45 +00:00
|
|
|
pub fn set_name(name: &CStr) {
|
2015-04-15 05:13:57 +00:00
|
|
|
unsafe {
|
2016-03-25 04:46:45 +00:00
|
|
|
libc::pthread_set_name_np(libc::pthread_self(), name.as_ptr());
|
2015-04-15 05:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
2016-03-25 04:46:45 +00:00
|
|
|
pub fn set_name(name: &CStr) {
|
2015-04-15 05:13:57 +00:00
|
|
|
unsafe {
|
2016-03-25 04:46:45 +00:00
|
|
|
libc::pthread_setname_np(name.as_ptr());
|
2015-04-15 05:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-20 15:39:52 +00:00
|
|
|
#[cfg(target_os = "netbsd")]
|
2016-03-25 04:46:45 +00:00
|
|
|
pub fn set_name(name: &CStr) {
|
|
|
|
use ffi::CString;
|
2015-09-20 15:39:52 +00:00
|
|
|
let cname = CString::new(&b"%s"[..]).unwrap();
|
|
|
|
unsafe {
|
2015-11-03 00:23:22 +00:00
|
|
|
libc::pthread_setname_np(libc::pthread_self(), cname.as_ptr(),
|
2016-03-25 04:46:45 +00:00
|
|
|
name.as_ptr() as *mut libc::c_void);
|
2015-09-20 15:39:52 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-26 05:41:24 +00:00
|
|
|
#[cfg(any(target_env = "newlib",
|
|
|
|
target_os = "solaris",
|
|
|
|
target_os = "haiku",
|
2017-08-18 09:50:20 +00:00
|
|
|
target_os = "l4re",
|
2016-09-26 05:41:24 +00:00
|
|
|
target_os = "emscripten"))]
|
2016-03-25 04:46:45 +00:00
|
|
|
pub fn set_name(_name: &CStr) {
|
2016-09-26 05:41:24 +00:00
|
|
|
// Newlib, Illumos, Haiku, and Emscripten have no way to set a thread name.
|
2016-09-25 04:38:56 +00:00
|
|
|
}
|
2016-10-18 20:43:18 +00:00
|
|
|
#[cfg(target_os = "fuchsia")]
|
|
|
|
pub fn set_name(_name: &CStr) {
|
2016-10-21 01:09:52 +00:00
|
|
|
// FIXME: determine whether Fuchsia has a way to set a thread name.
|
2016-10-18 20:43:18 +00:00
|
|
|
}
|
2016-09-25 04:38:56 +00:00
|
|
|
|
2015-04-15 05:13:57 +00:00
|
|
|
pub fn sleep(dur: Duration) {
|
2016-06-19 13:58:40 +00:00
|
|
|
let mut secs = dur.as_secs();
|
2017-10-19 17:49:59 +00:00
|
|
|
let mut nsecs = dur.subsec_nanos() as _;
|
2015-04-15 05:13:57 +00:00
|
|
|
|
|
|
|
// If we're awoken with a signal then the return value will be -1 and
|
|
|
|
// nanosleep will fill in `ts` with the remaining time.
|
|
|
|
unsafe {
|
2016-06-19 13:58:40 +00:00
|
|
|
while secs > 0 || nsecs > 0 {
|
|
|
|
let mut ts = libc::timespec {
|
|
|
|
tv_sec: cmp::min(libc::time_t::max_value() as u64, secs) as libc::time_t,
|
|
|
|
tv_nsec: nsecs,
|
|
|
|
};
|
|
|
|
secs -= ts.tv_sec as u64;
|
|
|
|
if libc::nanosleep(&ts, &mut ts) == -1 {
|
|
|
|
assert_eq!(os::errno(), libc::EINTR);
|
|
|
|
secs += ts.tv_sec as u64;
|
|
|
|
nsecs = ts.tv_nsec;
|
|
|
|
} else {
|
|
|
|
nsecs = 0;
|
|
|
|
}
|
2015-04-15 05:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn join(self) {
|
|
|
|
unsafe {
|
2015-11-03 00:23:22 +00:00
|
|
|
let ret = libc::pthread_join(self.id, ptr::null_mut());
|
2015-04-15 05:13:57 +00:00
|
|
|
mem::forget(self);
|
2017-08-27 02:36:46 +00:00
|
|
|
assert!(ret == 0,
|
|
|
|
"failed to join thread: {}", io::Error::from_raw_os_error(ret));
|
2015-04-15 05:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-04 02:58:00 +00:00
|
|
|
|
|
|
|
pub fn id(&self) -> libc::pthread_t { self.id }
|
|
|
|
|
|
|
|
pub fn into_id(self) -> libc::pthread_t {
|
|
|
|
let id = self.id;
|
|
|
|
mem::forget(self);
|
|
|
|
id
|
|
|
|
}
|
2015-04-15 05:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Drop for Thread {
|
|
|
|
fn drop(&mut self) {
|
2015-11-03 00:23:22 +00:00
|
|
|
let ret = unsafe { libc::pthread_detach(self.id) };
|
2015-04-15 05:13:57 +00:00
|
|
|
debug_assert_eq!(ret, 0);
|
|
|
|
}
|
|
|
|
}
|
2014-11-24 03:21:17 +00:00
|
|
|
|
2015-12-29 22:33:58 +00:00
|
|
|
#[cfg(all(not(all(target_os = "linux", not(target_env = "musl"))),
|
2016-04-04 14:18:44 +00:00
|
|
|
not(target_os = "freebsd"),
|
2015-01-29 07:19:28 +00:00
|
|
|
not(target_os = "macos"),
|
2015-01-17 07:51:04 +00:00
|
|
|
not(target_os = "bitrig"),
|
2015-09-21 17:16:24 +00:00
|
|
|
not(all(target_os = "netbsd", not(target_vendor = "rumprun"))),
|
2016-01-21 16:30:22 +00:00
|
|
|
not(target_os = "openbsd"),
|
2016-01-28 11:02:31 +00:00
|
|
|
not(target_os = "solaris")))]
|
2016-01-23 07:49:57 +00:00
|
|
|
#[cfg_attr(test, allow(dead_code))]
|
2014-11-24 03:21:17 +00:00
|
|
|
pub mod guard {
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
use ops::Range;
|
|
|
|
pub type Guard = Range<usize>;
|
|
|
|
pub unsafe fn current() -> Option<Guard> { None }
|
|
|
|
pub unsafe fn init() -> Option<Guard> { None }
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
|
|
|
|
2015-01-29 07:19:28 +00:00
|
|
|
|
2015-12-29 22:33:58 +00:00
|
|
|
#[cfg(any(all(target_os = "linux", not(target_env = "musl")),
|
2016-04-04 14:18:44 +00:00
|
|
|
target_os = "freebsd",
|
2015-01-29 07:19:28 +00:00
|
|
|
target_os = "macos",
|
2015-01-17 07:51:04 +00:00
|
|
|
target_os = "bitrig",
|
2015-09-21 17:16:24 +00:00
|
|
|
all(target_os = "netbsd", not(target_vendor = "rumprun")),
|
2016-01-21 16:30:22 +00:00
|
|
|
target_os = "openbsd",
|
2016-01-28 11:02:31 +00:00
|
|
|
target_os = "solaris"))]
|
2016-01-23 07:49:57 +00:00
|
|
|
#[cfg_attr(test, allow(dead_code))]
|
2014-11-24 03:21:17 +00:00
|
|
|
pub mod guard {
|
2016-01-23 07:49:57 +00:00
|
|
|
use libc;
|
2018-03-18 14:02:06 +00:00
|
|
|
use libc::{mmap, munmap};
|
2015-11-03 00:23:22 +00:00
|
|
|
use libc::{PROT_NONE, MAP_PRIVATE, MAP_ANON, MAP_FAILED, MAP_FIXED};
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
use ops::Range;
|
2015-03-13 03:21:17 +00:00
|
|
|
use sys::os;
|
2014-11-24 03:21:17 +00:00
|
|
|
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
// This is initialized in init() and only read from after
|
|
|
|
static mut PAGE_SIZE: usize = 0;
|
|
|
|
|
|
|
|
pub type Guard = Range<usize>;
|
|
|
|
|
|
|
|
#[cfg(target_os = "solaris")]
|
|
|
|
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
|
|
|
|
let mut current_stack: libc::stack_t = ::mem::zeroed();
|
|
|
|
assert_eq!(libc::stack_getbounds(&mut current_stack), 0);
|
|
|
|
Some(current_stack.ss_sp)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
2015-07-16 18:59:53 +00:00
|
|
|
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
let stackaddr = libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize -
|
|
|
|
libc::pthread_get_stacksize_np(libc::pthread_self());
|
|
|
|
Some(stackaddr as *mut libc::c_void)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(target_os = "openbsd", target_os = "bitrig"))]
|
|
|
|
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
|
|
|
|
let mut current_stack: libc::stack_t = ::mem::zeroed();
|
|
|
|
assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(),
|
|
|
|
&mut current_stack), 0);
|
|
|
|
|
|
|
|
let extra = if cfg!(target_os = "bitrig") {3} else {1} * PAGE_SIZE;
|
|
|
|
let stackaddr = if libc::pthread_main_np() == 1 {
|
|
|
|
// main thread
|
|
|
|
current_stack.ss_sp as usize - current_stack.ss_size + extra
|
|
|
|
} else {
|
|
|
|
// new thread
|
|
|
|
current_stack.ss_sp as usize - current_stack.ss_size
|
|
|
|
};
|
|
|
|
Some(stackaddr as *mut libc::c_void)
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
|
|
|
|
2016-04-05 03:25:32 +00:00
|
|
|
#[cfg(any(target_os = "android", target_os = "freebsd",
|
2017-08-18 09:50:20 +00:00
|
|
|
target_os = "linux", target_os = "netbsd", target_os = "l4re"))]
|
2016-04-04 14:18:44 +00:00
|
|
|
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
|
|
|
|
let mut ret = None;
|
|
|
|
let mut attr: libc::pthread_attr_t = ::mem::zeroed();
|
|
|
|
assert_eq!(libc::pthread_attr_init(&mut attr), 0);
|
2016-04-05 03:25:32 +00:00
|
|
|
#[cfg(target_os = "freebsd")]
|
|
|
|
let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr);
|
|
|
|
#[cfg(not(target_os = "freebsd"))]
|
|
|
|
let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr);
|
|
|
|
if e == 0 {
|
2016-01-23 07:49:57 +00:00
|
|
|
let mut stackaddr = ::ptr::null_mut();
|
2015-07-16 18:59:53 +00:00
|
|
|
let mut stacksize = 0;
|
2015-11-03 00:23:22 +00:00
|
|
|
assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
|
|
|
|
&mut stacksize), 0);
|
2015-07-16 18:59:53 +00:00
|
|
|
ret = Some(stackaddr);
|
|
|
|
}
|
2015-11-03 00:23:22 +00:00
|
|
|
assert_eq!(libc::pthread_attr_destroy(&mut attr), 0);
|
2015-07-16 18:59:53 +00:00
|
|
|
ret
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
|
|
|
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
pub unsafe fn init() -> Option<Guard> {
|
|
|
|
PAGE_SIZE = os::page_size();
|
|
|
|
|
2017-12-09 01:32:04 +00:00
|
|
|
let mut stackaddr = get_stack_start()?;
|
2015-01-11 03:52:50 +00:00
|
|
|
|
|
|
|
// Ensure stackaddr is page aligned! A parent process might
|
|
|
|
// have reset RLIMIT_STACK to be non-page aligned. The
|
|
|
|
// pthread_attr_getstack() reports the usable stack area
|
|
|
|
// stackaddr < stackaddr + stacksize, so if stackaddr is not
|
|
|
|
// page-aligned, calculate the fix such that stackaddr <
|
|
|
|
// new_page_aligned_stackaddr < stackaddr + stacksize
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
let remainder = (stackaddr as usize) % PAGE_SIZE;
|
2015-01-11 03:52:50 +00:00
|
|
|
if remainder != 0 {
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
stackaddr = ((stackaddr as usize) + PAGE_SIZE - remainder)
|
2015-01-11 03:52:50 +00:00
|
|
|
as *mut libc::c_void;
|
|
|
|
}
|
2014-11-24 03:21:17 +00:00
|
|
|
|
2017-07-05 19:03:17 +00:00
|
|
|
if cfg!(target_os = "linux") {
|
|
|
|
// Linux doesn't allocate the whole stack right away, and
|
|
|
|
// the kernel has its own stack-guard mechanism to fault
|
|
|
|
// when growing too close to an existing mapping. If we map
|
|
|
|
// our own guard, then the kernel starts enforcing a rather
|
|
|
|
// large gap above that, rendering much of the possible
|
|
|
|
// stack space useless. See #43052.
|
|
|
|
//
|
|
|
|
// Instead, we'll just note where we expect rlimit to start
|
|
|
|
// faulting, so our handler can report "stack overflow", and
|
|
|
|
// trust that the kernel's own stack guard will work.
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
let stackaddr = stackaddr as usize;
|
|
|
|
Some(stackaddr - PAGE_SIZE..stackaddr)
|
2016-04-04 14:18:44 +00:00
|
|
|
} else {
|
2017-07-05 19:03:17 +00:00
|
|
|
// Reallocate the last page of the stack.
|
|
|
|
// This ensures SIGBUS will be raised on
|
|
|
|
// stack overflow.
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
let result = mmap(stackaddr, PAGE_SIZE, PROT_NONE,
|
2017-07-05 19:03:17 +00:00
|
|
|
MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
|
|
|
|
|
|
|
|
if result != stackaddr || result == MAP_FAILED {
|
|
|
|
panic!("failed to allocate a guard page");
|
|
|
|
}
|
|
|
|
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
let guardaddr = stackaddr as usize;
|
2017-07-05 19:03:17 +00:00
|
|
|
let offset = if cfg!(target_os = "freebsd") {
|
|
|
|
2
|
|
|
|
} else {
|
|
|
|
1
|
|
|
|
};
|
2014-11-24 03:21:17 +00:00
|
|
|
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
Some(guardaddr..guardaddr + offset * PAGE_SIZE)
|
2017-07-05 19:03:17 +00:00
|
|
|
}
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
|
|
|
|
2018-03-18 14:02:06 +00:00
|
|
|
pub unsafe fn deinit() {
|
|
|
|
if !cfg!(target_os = "linux") {
|
|
|
|
if let Some(mut stackaddr) = get_stack_start() {
|
|
|
|
// Ensure address is aligned. Same as above.
|
|
|
|
let remainder = (stackaddr as usize) % PAGE_SIZE;
|
|
|
|
if remainder != 0 {
|
|
|
|
stackaddr = ((stackaddr as usize) + PAGE_SIZE - remainder)
|
|
|
|
as *mut libc::c_void;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Undo the guard page mapping.
|
|
|
|
if munmap(stackaddr, PAGE_SIZE) != 0 {
|
|
|
|
panic!("unable to deallocate the guard page");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
#[cfg(any(target_os = "macos",
|
|
|
|
target_os = "bitrig",
|
|
|
|
target_os = "openbsd",
|
|
|
|
target_os = "solaris"))]
|
|
|
|
pub unsafe fn current() -> Option<Guard> {
|
|
|
|
let stackaddr = get_stack_start()? as usize;
|
|
|
|
Some(stackaddr - PAGE_SIZE..stackaddr)
|
2015-01-29 07:19:28 +00:00
|
|
|
}
|
|
|
|
|
2016-04-05 03:25:32 +00:00
|
|
|
#[cfg(any(target_os = "android", target_os = "freebsd",
|
2017-08-18 09:50:20 +00:00
|
|
|
target_os = "linux", target_os = "netbsd", target_os = "l4re"))]
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
pub unsafe fn current() -> Option<Guard> {
|
2015-07-16 18:59:53 +00:00
|
|
|
let mut ret = None;
|
2016-01-23 07:49:57 +00:00
|
|
|
let mut attr: libc::pthread_attr_t = ::mem::zeroed();
|
2015-11-03 00:23:22 +00:00
|
|
|
assert_eq!(libc::pthread_attr_init(&mut attr), 0);
|
2016-04-05 03:25:32 +00:00
|
|
|
#[cfg(target_os = "freebsd")]
|
|
|
|
let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr);
|
|
|
|
#[cfg(not(target_os = "freebsd"))]
|
|
|
|
let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr);
|
|
|
|
if e == 0 {
|
2015-07-16 18:59:53 +00:00
|
|
|
let mut guardsize = 0;
|
2015-11-03 00:23:22 +00:00
|
|
|
assert_eq!(libc::pthread_attr_getguardsize(&attr, &mut guardsize), 0);
|
2015-07-16 18:59:53 +00:00
|
|
|
if guardsize == 0 {
|
|
|
|
panic!("there is no guard page");
|
|
|
|
}
|
2016-01-23 07:49:57 +00:00
|
|
|
let mut stackaddr = ::ptr::null_mut();
|
2015-07-16 18:59:53 +00:00
|
|
|
let mut size = 0;
|
2015-11-03 00:23:22 +00:00
|
|
|
assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
|
|
|
|
&mut size), 0);
|
2015-07-16 18:59:53 +00:00
|
|
|
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
let stackaddr = stackaddr as usize;
|
2016-04-05 03:25:32 +00:00
|
|
|
ret = if cfg!(target_os = "freebsd") {
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
// FIXME does freebsd really fault *below* the guard addr?
|
|
|
|
let guardaddr = stackaddr - guardsize;
|
|
|
|
Some(guardaddr - PAGE_SIZE..guardaddr)
|
2016-04-05 03:25:32 +00:00
|
|
|
} else if cfg!(target_os = "netbsd") {
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
Some(stackaddr - guardsize..stackaddr)
|
|
|
|
} else if cfg!(all(target_os = "linux", target_env = "gnu")) {
|
|
|
|
// glibc used to include the guard area within the stack, as noted in the BUGS
|
|
|
|
// section of `man pthread_attr_getguardsize`. This has been corrected starting
|
|
|
|
// with glibc 2.27, and in some distro backports, so the guard is now placed at the
|
|
|
|
// end (below) the stack. There's no easy way for us to know which we have at
|
|
|
|
// runtime, so we'll just match any fault in the range right above or below the
|
|
|
|
// stack base to call that fault a stack overflow.
|
|
|
|
Some(stackaddr - guardsize..stackaddr + guardsize)
|
2015-09-20 15:39:52 +00:00
|
|
|
} else {
|
Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads. The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.
Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes. Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.
For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack. However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow. This fixes #47863.
2018-01-31 19:41:29 +00:00
|
|
|
Some(stackaddr..stackaddr + guardsize)
|
2015-09-20 15:39:52 +00:00
|
|
|
};
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
2015-11-03 00:23:22 +00:00
|
|
|
assert_eq!(libc::pthread_attr_destroy(&mut attr), 0);
|
2015-09-07 22:36:29 +00:00
|
|
|
ret
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// glibc >= 2.15 has a __pthread_get_minstack() function that returns
|
|
|
|
// PTHREAD_STACK_MIN plus however many bytes are needed for thread-local
|
|
|
|
// storage. We need that information to avoid blowing up when a small stack
|
|
|
|
// is created in an application with big thread-local storage requirements.
|
|
|
|
// See #6233 for rationale and details.
|
|
|
|
#[cfg(target_os = "linux")]
|
std: Stabilize library APIs for 1.5
This commit stabilizes and deprecates library APIs whose FCP has closed in the
last cycle, specifically:
Stabilized APIs:
* `fs::canonicalize`
* `Path::{metadata, symlink_metadata, canonicalize, read_link, read_dir, exists,
is_file, is_dir}` - all moved to inherent methods from the `PathExt` trait.
* `Formatter::fill`
* `Formatter::width`
* `Formatter::precision`
* `Formatter::sign_plus`
* `Formatter::sign_minus`
* `Formatter::alternate`
* `Formatter::sign_aware_zero_pad`
* `string::ParseError`
* `Utf8Error::valid_up_to`
* `Iterator::{cmp, partial_cmp, eq, ne, lt, le, gt, ge}`
* `<[T]>::split_{first,last}{,_mut}`
* `Condvar::wait_timeout` - note that `wait_timeout_ms` is not yet deprecated
but will be once 1.5 is released.
* `str::{R,}MatchIndices`
* `str::{r,}match_indices`
* `char::from_u32_unchecked`
* `VecDeque::insert`
* `VecDeque::shrink_to_fit`
* `VecDeque::as_slices`
* `VecDeque::as_mut_slices`
* `VecDeque::swap_remove_front` - (renamed from `swap_front_remove`)
* `VecDeque::swap_remove_back` - (renamed from `swap_back_remove`)
* `Vec::resize`
* `str::slice_mut_unchecked`
* `FileTypeExt`
* `FileTypeExt::{is_block_device, is_char_device, is_fifo, is_socket}`
* `BinaryHeap::from` - `from_vec` deprecated in favor of this
* `BinaryHeap::into_vec` - plus a `Into` impl
* `BinaryHeap::into_sorted_vec`
Deprecated APIs
* `slice::ref_slice`
* `slice::mut_ref_slice`
* `iter::{range_inclusive, RangeInclusive}`
* `std::dynamic_lib`
Closes #27706
Closes #27725
cc #27726 (align not stabilized yet)
Closes #27734
Closes #27737
Closes #27742
Closes #27743
Closes #27772
Closes #27774
Closes #27777
Closes #27781
cc #27788 (a few remaining methods though)
Closes #27790
Closes #27793
Closes #27796
Closes #27810
cc #28147 (not all parts stabilized)
2015-10-22 23:28:45 +00:00
|
|
|
#[allow(deprecated)]
|
2015-04-15 05:13:57 +00:00
|
|
|
fn min_stack_size(attr: *const libc::pthread_attr_t) -> usize {
|
2016-02-04 21:56:59 +00:00
|
|
|
weak!(fn __pthread_get_minstack(*const libc::pthread_attr_t) -> libc::size_t);
|
2015-03-23 04:58:19 +00:00
|
|
|
|
2016-02-04 21:56:59 +00:00
|
|
|
match __pthread_get_minstack.get() {
|
2016-10-08 13:48:28 +00:00
|
|
|
None => libc::PTHREAD_STACK_MIN,
|
|
|
|
Some(f) => unsafe { f(attr) },
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-23 07:48:06 +00:00
|
|
|
// No point in looking up __pthread_get_minstack() on non-glibc
|
|
|
|
// platforms.
|
2016-01-29 03:33:29 +00:00
|
|
|
#[cfg(all(not(target_os = "linux"),
|
|
|
|
not(target_os = "netbsd")))]
|
|
|
|
fn min_stack_size(_: *const libc::pthread_attr_t) -> usize {
|
2016-10-08 13:48:28 +00:00
|
|
|
libc::PTHREAD_STACK_MIN
|
2016-01-29 03:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_os = "netbsd")]
|
2015-04-15 05:13:57 +00:00
|
|
|
fn min_stack_size(_: *const libc::pthread_attr_t) -> usize {
|
2016-01-29 03:33:29 +00:00
|
|
|
2048 // just a guess
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|