Remove #[fixed_stack_segment] and #[rust_stack]

These two attributes are no longer useful now that Rust has decided to leave
segmented stacks behind. It is assumed that the rust task's stack is always
large enough to make an FFI call (due to the stack being very large).

There's always the case of stack overflow, however, to consider. This does not
change the behavior of stack overflow in Rust. This is still normally triggered
by the __morestack function and aborts the whole process.

C stack overflow will continue to corrupt the stack, however (as it did before
this commit as well). The future improvement of a guard page at the end of every
rust stack is still unimplemented and is intended to be the mechanism through
which we attempt to detect C stack overflow.

Closes #8822
Closes #10155
This commit is contained in:
Alex Crichton 2013-11-06 15:16:04 -08:00
parent 4059b5c4b3
commit 7755ffd013
111 changed files with 259 additions and 1045 deletions

View file

@ -144,21 +144,16 @@ pub mod dl {
use result::*;
pub unsafe fn open_external(filename: &path::Path) -> *libc::c_void {
#[fixed_stack_segment]; #[inline(never)];
do filename.with_c_str |raw_name| {
dlopen(raw_name, Lazy as libc::c_int)
}
}
pub unsafe fn open_internal() -> *libc::c_void {
#[fixed_stack_segment]; #[inline(never)];
dlopen(ptr::null(), Lazy as libc::c_int)
}
pub fn check_for_errors_in<T>(f: &fn()->T) -> Result<T, ~str> {
#[fixed_stack_segment]; #[inline(never)];
unsafe {
// dlerror isn't thread safe, so we need to lock around this entire
// sequence. `atomically` asserts that we don't do anything that
@ -184,13 +179,9 @@ pub mod dl {
}
pub unsafe fn symbol(handle: *libc::c_void, symbol: *libc::c_char) -> *libc::c_void {
#[fixed_stack_segment]; #[inline(never)];
dlsym(handle, symbol)
}
pub unsafe fn close(handle: *libc::c_void) {
#[fixed_stack_segment]; #[inline(never)];
dlclose(handle); ()
}
@ -225,21 +216,18 @@ pub mod dl {
use result::*;
pub unsafe fn open_external(filename: &path::Path) -> *libc::c_void {
#[fixed_stack_segment]; #[inline(never)];
do os::win32::as_utf16_p(filename.as_str().unwrap()) |raw_name| {
LoadLibraryW(raw_name)
}
}
pub unsafe fn open_internal() -> *libc::c_void {
#[fixed_stack_segment]; #[inline(never)];
let handle = ptr::null();
GetModuleHandleExW(0 as libc::DWORD, ptr::null(), &handle as **libc::c_void);
handle
}
pub fn check_for_errors_in<T>(f: &fn()->T) -> Result<T, ~str> {
#[fixed_stack_segment]; #[inline(never)];
unsafe {
do atomically {
SetLastError(0);
@ -257,11 +245,9 @@ pub mod dl {
}
pub unsafe fn symbol(handle: *libc::c_void, symbol: *libc::c_char) -> *libc::c_void {
#[fixed_stack_segment]; #[inline(never)];
GetProcAddress(handle, symbol)
}
pub unsafe fn close(handle: *libc::c_void) {
#[fixed_stack_segment]; #[inline(never)];
FreeLibrary(handle); ()
}

View file

@ -369,28 +369,16 @@ extern "rust-intrinsic" {
pub fn powif32(a: f32, x: i32) -> f32;
pub fn powif64(a: f64, x: i32) -> f64;
// the following kill the stack canary without
// `fixed_stack_segment`. This possibly only affects the f64
// variants, but it's hard to be sure since it seems to only
// occur with fairly specific arguments.
#[fixed_stack_segment]
pub fn sinf32(x: f32) -> f32;
#[fixed_stack_segment]
pub fn sinf64(x: f64) -> f64;
#[fixed_stack_segment]
pub fn cosf32(x: f32) -> f32;
#[fixed_stack_segment]
pub fn cosf64(x: f64) -> f64;
#[fixed_stack_segment]
pub fn powf32(a: f32, x: f32) -> f32;
#[fixed_stack_segment]
pub fn powf64(a: f64, x: f64) -> f64;
#[fixed_stack_segment]
pub fn expf32(x: f32) -> f32;
#[fixed_stack_segment]
pub fn expf64(x: f64) -> f64;
pub fn exp2f32(x: f32) -> f32;

View file

@ -72,7 +72,6 @@ fn test_run_in_bare_thread_exchange() {
/// can't run correctly un-altered. Valgrind is there to help
/// you notice weirdness in normal, un-doctored code paths!
pub fn running_on_valgrind() -> bool {
#[fixed_stack_segment]; #[inline(never)];
unsafe { rust_running_on_valgrind() != 0 }
}

View file

@ -475,12 +475,14 @@ impl<T:Send> Exclusive<T> {
}
}
externfn!(fn rust_create_little_lock() -> rust_little_lock)
externfn!(fn rust_destroy_little_lock(lock: rust_little_lock))
externfn!(fn rust_lock_little_lock(lock: rust_little_lock))
externfn!(fn rust_unlock_little_lock(lock: rust_little_lock))
externfn!(fn rust_signal_little_lock(lock: rust_little_lock))
externfn!(fn rust_wait_little_lock(lock: rust_little_lock))
extern {
fn rust_create_little_lock() -> rust_little_lock;
fn rust_destroy_little_lock(lock: rust_little_lock);
fn rust_lock_little_lock(lock: rust_little_lock);
fn rust_unlock_little_lock(lock: rust_little_lock);
fn rust_signal_little_lock(lock: rust_little_lock);
fn rust_wait_little_lock(lock: rust_little_lock);
}
#[cfg(test)]
mod tests {