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

@ -25,7 +25,6 @@ pub mod rustrt {
}
}
#[fixed_stack_segment] #[inline(never)]
pub fn fact(n: uint) -> uint {
unsafe {
info!("n = {}", n);

View file

@ -91,7 +91,6 @@ fn vector<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint, dist: &[uint]) {
}
}
#[fixed_stack_segment]
fn main() {
let args = os::args();
let n_keys = {

View file

@ -91,7 +91,6 @@ fn fannkuch_redux(n: i32) -> i32 {
}
}
#[fixed_stack_segment]
fn main() {
let n: i32 = FromStr::from_str(os::args()[1]).unwrap();
println!("Pfannkuchen({}) = {}", n as int, fannkuch_redux(n) as int);

View file

@ -184,7 +184,6 @@ impl RandomFasta {
}
}
#[fixed_stack_segment]
fn main() {
let n: uint = FromStr::from_str(os::args()[1]).unwrap();

View file

@ -243,8 +243,6 @@ fn read_stdin() -> ~[u8] {
}
}
#[inline(never)]
#[fixed_stack_segment]
fn generate_frequencies(frequencies: &mut Table,
mut input: &[u8],
frame: i32) {
@ -264,8 +262,6 @@ fn generate_frequencies(frequencies: &mut Table,
}
}
#[inline(never)]
#[fixed_stack_segment]
fn print_frequencies(frequencies: &Table, frame: i32) {
let mut vector = ~[];
for frequencies.each |entry| {
@ -289,7 +285,6 @@ fn print_occurrences(frequencies: &mut Table, occurrence: &'static str) {
frequencies.lookup(Code::pack(occurrence), PrintCallback(occurrence))
}
#[fixed_stack_segment]
fn main() {
let input = read_stdin();

View file

@ -8,7 +8,6 @@ use std::os;
static ITER: uint = 50;
static LIMIT: f64 = 2.0;
#[fixed_stack_segment]
fn main() {
unsafe {
let w: i32 = FromStr::from_str(os::args()[1]).unwrap();

View file

@ -161,7 +161,6 @@ fn pidigits(n: u32) {
}
}
#[fixed_stack_segment]
fn main() {
let n: u32 = FromStr::from_str(os::args()[1]).get();
pidigits(n);

View file

@ -90,7 +90,6 @@ static COMPLEMENTS: [u8, ..256] = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
];
#[fixed_stack_segment]
fn main() {
unsafe {
let mode = "r";

View file

@ -52,7 +52,6 @@ fn mult_AtAv(v: &mut [f64], out: &mut [f64], tmp: &mut [f64]) {
mult_Atv(tmp, out);
}
#[fixed_stack_segment]
fn main() {
let n: uint = FromStr::from_str(os::args()[1]).unwrap();
let mut u = vec::from_elem(n, 1f64);

View file

@ -1,23 +0,0 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// 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.
extern fn f() {
}
extern fn call1() {
f(); // OK from another extern fn!
}
fn call2() {
f(); //~ ERROR invoking non-Rust fn
}
fn main() {}

View file

@ -1,24 +0,0 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// 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.
extern {
fn rust_get_test_int() -> std::libc::intptr_t;
}
trait A {
fn foo() {
unsafe {
rust_get_test_int(); //~ ERROR invoking non-Rust fn
}
}
}
fn main() {
}

View file

@ -10,7 +10,6 @@
// Exercise the unused_unsafe attribute in some positive and negative cases
#[allow(cstack)];
#[deny(unused_unsafe)];
mod foo {

View file

@ -18,7 +18,6 @@ extern {
extern "C" fn bar(f: int, x: u8) {}
#[fixed_stack_segment]
fn main() {
unsafe {
foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied

View file

@ -14,7 +14,6 @@ extern mod anonexternmod;
use anonexternmod::rust_get_test_int;
#[fixed_stack_segment]
pub fn main() {
unsafe {
rust_get_test_int();

View file

@ -15,7 +15,6 @@ extern {
fn rust_get_test_int() -> libc::intptr_t;
}
#[fixed_stack_segment]
pub fn main() {
unsafe {
let _ = rust_get_test_int();

View file

@ -18,12 +18,10 @@ mod libc {
}
}
#[fixed_stack_segment]
fn atol(s: ~str) -> int {
s.with_c_str(|x| unsafe { libc::atol(x) as int })
}
#[fixed_stack_segment]
fn atoll(s: ~str) -> i64 {
s.with_c_str(|x| unsafe { libc::atoll(x) as i64 })
}

View file

@ -60,8 +60,6 @@ fn test_destroy_actually_kills(force: bool) {
#[cfg(windows)]
fn process_exists(pid: libc::pid_t) -> bool {
#[fixed_stack_segment];
use std::libc::types::os::arch::extra::DWORD;
use std::libc::funcs::extra::kernel32::{CloseHandle, GetExitCodeProcess, OpenProcess};
use std::libc::consts::os::extra::{FALSE, PROCESS_QUERY_INFORMATION, STILL_ACTIVE };

View file

@ -28,7 +28,6 @@ extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
}
}
#[fixed_stack_segment]
fn count(n: uint) -> uint {
unsafe {
info!("n = {}", n);

View file

@ -29,7 +29,6 @@ extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
}
}
#[fixed_stack_segment] #[inline(never)]
fn count(n: uint) -> uint {
unsafe {
info!("n = {}", n);

View file

@ -13,8 +13,6 @@
extern fn f(x: uint) -> uint { x * 2 }
pub fn main() {
#[fixed_stack_segment];
let x = f(22);
assert_eq!(x, 44);
}

View file

@ -28,7 +28,6 @@ extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
}
}
#[fixed_stack_segment] #[inline(never)]
fn fact(n: uint) -> uint {
unsafe {
info!("n = {}", n);

View file

@ -33,7 +33,6 @@ extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
}
}
#[fixed_stack_segment] #[inline(never)]
fn count(n: uint) -> uint {
unsafe {
info!("n = {}", n);

View file

@ -13,7 +13,6 @@
extern mod externcallback(vers = "0.1");
#[fixed_stack_segment] #[inline(never)]
fn fact(n: uint) -> uint {
unsafe {
info!("n = {}", n);

View file

@ -22,7 +22,6 @@ extern {
pub fn rust_dbg_extern_identity_TwoU16s(v: TwoU16s) -> TwoU16s;
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
let x = TwoU16s {one: 22, two: 23};

View file

@ -20,7 +20,6 @@ extern {
pub fn rust_dbg_extern_identity_TwoU32s(v: TwoU32s) -> TwoU32s;
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
let x = TwoU32s {one: 22, two: 23};

View file

@ -20,7 +20,6 @@ extern {
pub fn rust_dbg_extern_identity_TwoU64s(u: TwoU64s) -> TwoU64s;
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
let x = TwoU64s {one: 22, two: 23};

View file

@ -25,7 +25,6 @@ extern {
pub fn rust_dbg_extern_identity_TwoU64s(v: TwoU64s) -> TwoU64s;
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
let x = TwoU64s {one: 22, two: 23};

View file

@ -22,7 +22,6 @@ extern {
pub fn rust_dbg_extern_identity_TwoU8s(v: TwoU8s) -> TwoU8s;
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
let x = TwoU8s {one: 22, two: 23};

View file

@ -14,7 +14,6 @@ extern {
pub fn rust_dbg_extern_identity_u8(v: u8) -> u8;
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
assert_eq!(22_u8, rust_dbg_extern_identity_u8(22_u8));

View file

@ -12,7 +12,6 @@ extern {
pub fn rust_dbg_extern_identity_double(v: f64) -> f64;
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
assert_eq!(22.0_f64, rust_dbg_extern_identity_double(22.0_f64));

View file

@ -14,7 +14,6 @@ extern {
pub fn rust_dbg_extern_identity_u32(v: u32) -> u32;
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
assert_eq!(22_u32, rust_dbg_extern_identity_u32(22_u32));

View file

@ -14,7 +14,6 @@ extern {
pub fn rust_dbg_extern_identity_u64(v: u64) -> u64;
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
assert_eq!(22_u64, rust_dbg_extern_identity_u64(22_u64));

View file

@ -16,7 +16,6 @@ extern {
pub fn rust_dbg_extern_return_TwoU16s() -> TwoU16s;
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
let y = rust_dbg_extern_return_TwoU16s();

View file

@ -16,7 +16,6 @@ extern {
pub fn rust_dbg_extern_return_TwoU32s() -> TwoU32s;
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
let y = rust_dbg_extern_return_TwoU32s();

View file

@ -18,7 +18,6 @@ extern {
pub fn rust_dbg_extern_return_TwoU64s() -> TwoU64s;
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
let y = rust_dbg_extern_return_TwoU64s();

View file

@ -16,7 +16,6 @@ extern {
pub fn rust_dbg_extern_return_TwoU8s() -> TwoU8s;
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
let y = rust_dbg_extern_return_TwoU8s();

View file

@ -33,7 +33,6 @@ extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
}
}
#[fixed_stack_segment] #[inline(never)]
fn count(n: uint) -> uint {
unsafe {
rustrt::rust_dbg_call(cb, n)

View file

@ -29,7 +29,6 @@ extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
}
}
#[fixed_stack_segment] #[inline(never)]
fn count(n: uint) -> uint {
unsafe {
task::deschedule();

View file

@ -2,8 +2,10 @@ use std::cast;
use std::libc;
use std::unstable::run_in_bare_thread;
externfn!(fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t),
data: libc::uintptr_t) -> libc::uintptr_t)
extern {
fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t),
data: libc::uintptr_t) -> libc::uintptr_t;
}
pub fn main() {
unsafe {

View file

@ -29,7 +29,6 @@ mod rustrt2 {
}
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
rustrt1::rust_get_test_int();

View file

@ -20,7 +20,6 @@ mod libc {
}
}
#[fixed_stack_segment] #[inline(never)]
fn strlen(str: ~str) -> uint {
// C string is terminated with a zero
do str.with_c_str |buf| {

View file

@ -18,7 +18,6 @@ mod rustrt {
}
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
rustrt::rust_get_test_int();

View file

@ -17,7 +17,6 @@
extern mod foreign_lib;
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
let _foo = foreign_lib::rustrt::rust_get_test_int();

View file

@ -19,7 +19,6 @@ fn to_c_int(v: &mut int) -> &mut c_int {
}
}
#[fixed_stack_segment] #[inline(never)]
fn lgamma(n: c_double, value: &mut int) -> c_double {
unsafe {
return m::lgamma(n, to_c_int(value));

View file

@ -14,7 +14,6 @@ pub mod Bar {
}
extern {
#[rust_stack]
pub fn foo(v: *Foo) -> Foo;
}
}

View file

@ -15,7 +15,6 @@ extern {
}
trait A {
#[fixed_stack_segment]
fn foo() {
unsafe {
rust_get_test_int();

View file

@ -4,7 +4,6 @@ use std::libc;
pub struct Fd(c_int);
impl Drop for Fd {
#[fixed_stack_segment] #[inline(never)]
fn drop(&mut self) {
unsafe {
libc::close(**self);

View file

@ -6,7 +6,6 @@ mod a {
}
}
#[fixed_stack_segment] #[inline(never)]
pub fn main() {
unsafe {
a::free(transmute(0));

View file

@ -27,7 +27,6 @@ struct Ccx {
x: int
}
#[fixed_stack_segment] #[inline(never)]
fn alloc<'a>(_bcx : &'a arena) -> &'a Bcx<'a> {
unsafe {
cast::transmute(libc::malloc(mem::size_of::<Bcx<'a>>()
@ -39,7 +38,6 @@ fn h<'a>(bcx : &'a Bcx<'a>) -> &'a Bcx<'a> {
return alloc(bcx.fcx.arena);
}
#[fixed_stack_segment] #[inline(never)]
fn g(fcx : &Fcx) {
let bcx = Bcx { fcx: fcx };
let bcx2 = h(&bcx);

View file

@ -21,7 +21,6 @@ use std::rt::io;
use std::rt::io::fs;
fn rename_directory() {
#[fixed_stack_segment];
unsafe {
static U_RWX: i32 = (libc::S_IRUSR | libc::S_IWUSR | libc::S_IXUSR) as i32;

View file

@ -26,7 +26,6 @@ fn static_bound_set(a: &'static mut libc::c_int) {
*a = 3;
}
#[fixed_stack_segment] #[inline(never)]
unsafe fn run() {
assert!(rust_dbg_static_mut == 3);
rust_dbg_static_mut = 4;

View file

@ -23,7 +23,6 @@ mod rustrt {
}
}
#[fixed_stack_segment] #[inline(never)]
fn test1() {
unsafe {
let q = Quad { a: 0xaaaa_aaaa_aaaa_aaaa_u64,
@ -43,8 +42,6 @@ fn test1() {
}
#[cfg(target_arch = "x86_64")]
#[fixed_stack_segment]
#[inline(never)]
fn test2() {
unsafe {
let f = Floats { a: 1.234567890e-15_f64,

View file

@ -22,7 +22,6 @@ unsafe fn check<T>(expected: &str, f: &fn(*mut c_char) -> T) {
assert_eq!(expected, res.as_str().unwrap());
}
#[fixed_stack_segment]
pub fn main() {
unsafe {
@ -43,8 +42,6 @@ pub fn main() {
// A function that takes a function pointer
unsafe fn call(p: extern "C" unsafe fn(*mut c_char, *c_char, ...) -> c_int) {
#[fixed_stack_segment];
// Call with just the named parameter via fn pointer
do "Hello World\n".with_c_str |c| {
check("Hello World\n", |s| p(s, c));

View file

@ -28,7 +28,6 @@ mod kernel32 {
#[cfg(windows)]
#[fixed_stack_segment]
pub fn main() {
let heap = unsafe { kernel32::GetProcessHeap() };
let mem = unsafe { kernel32::HeapAlloc(heap, 0u32, 100u32) };