Skip to content

Commit 3fb6035

Browse files
committed
---
yaml --- r: 55849 b: refs/heads/master c: 848641f h: refs/heads/master i: 55847: b9b85bd v: v3
1 parent 178663e commit 3fb6035

File tree

9 files changed

+127
-43
lines changed

9 files changed

+127
-43
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 149047e55d8eace3ea9d005905577f17b25c54e2
2+
refs/heads/master: 848641fcb54c282f6bd616ef1d6ac06087d778f6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 79a2b2eafc3c766cecec8a5f76317693bae9ed17
55
refs/heads/try: 8eb2bab100b42f0ba751552d8eff00eb2134c55a

trunk/src/libcore/os.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,27 @@ pub fn make_dir(p: &Path, mode: c_int) -> bool {
639639
}
640640
}
641641

642+
/// Creates a directory with a given mode.
643+
/// Returns true iff creation
644+
/// succeeded. Also creates all intermediate subdirectories
645+
/// if they don't already exist, giving all of them the same mode.
646+
pub fn mkdir_recursive(p: &Path, mode: c_int) -> bool {
647+
if path_is_dir(p) {
648+
return true;
649+
}
650+
let parent = p.dir_path();
651+
debug!("mkdir_recursive: parent = %s",
652+
parent.to_str());
653+
if parent.to_str() == ~"."
654+
|| parent.to_str() == ~"/" { // !!!
655+
// No parent directories to create
656+
path_is_dir(&parent) && make_dir(p, mode)
657+
}
658+
else {
659+
mkdir_recursive(&parent, mode) && make_dir(p, mode)
660+
}
661+
}
662+
642663
/// Lists the contents of a directory
643664
#[allow(non_implicitly_copyable_typarams)]
644665
pub fn list_dir(p: &Path) -> ~[~str] {
@@ -1467,4 +1488,18 @@ mod tests {
14671488
assert!((remove_file(&out)));
14681489
}
14691490
}
1491+
1492+
#[test]
1493+
fn recursive_mkdir_ok() {
1494+
use libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
1495+
1496+
let root = os::tmpdir();
1497+
let path = "xy/z/zy";
1498+
let nested = root.push(path);
1499+
assert!(os::mkdir_recursive(&nested, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
1500+
assert!(os::path_is_dir(&root.push("xy")));
1501+
assert!(os::path_is_dir(&root.push("xy/z")));
1502+
assert!(os::path_is_dir(&nested));
1503+
}
1504+
14701505
}

trunk/src/librustpkg/path_util.rs

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use core::path::*;
1414
use core::{os, str};
1515
use core::option::*;
1616
use util::PkgId;
17+
use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
1718

1819
#[deriving(Eq)]
1920
pub enum OutputType { Main, Lib, Bench, Test }
@@ -25,34 +26,15 @@ pub fn rust_path() -> ~[Path] {
2526
~[Path(".")]
2627
}
2728

29+
static u_rwx: i32 = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
30+
2831
/// Creates a directory that is readable, writeable,
2932
/// and executable by the user. Returns true iff creation
3033
/// succeeded.
3134
pub fn make_dir_rwx(p: &Path) -> bool {
3235
use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
3336

34-
os::make_dir(p, (S_IRUSR | S_IWUSR | S_IXUSR) as i32)
35-
}
36-
37-
/// Creates a directory that is readable, writeable,
38-
/// and executable by the user. Returns true iff creation
39-
/// succeeded. Also creates all intermediate subdirectories
40-
/// if they don't already exist.
41-
pub fn mkdir_recursive(p: &Path) -> bool {
42-
if os::path_is_dir(p) {
43-
return true;
44-
}
45-
let parent = p.dir_path();
46-
debug!("mkdir_recursive: parent = %s",
47-
parent.to_str());
48-
if parent.to_str() == ~"."
49-
|| parent.to_str() == ~"/" { // !!!
50-
// No parent directories to create
51-
os::path_is_dir(&parent) && make_dir_rwx(p)
52-
}
53-
else {
54-
mkdir_recursive(&parent) && make_dir_rwx(p)
55-
}
37+
os::make_dir(p, u_rwx)
5638
}
5739

5840
/// Replace all occurrences of '-' in the stem part of path with '_'
@@ -130,7 +112,7 @@ pub fn build_pkg_id_in_workspace(pkgid: PkgId, workspace: &Path) -> Path {
130112
// n.b. Should actually use a target-specific
131113
// subdirectory of build/
132114
result = result.push(normalize(~pkgid.path).to_str());
133-
if os::path_exists(&result) || mkdir_recursive(&result) {
115+
if os::path_exists(&result) || os::mkdir_recursive(&result, u_rwx) {
134116
result
135117
}
136118
else {
@@ -148,19 +130,3 @@ pub fn mk_output_path(what: OutputType, short_name: ~str, dir: Path) -> Path {
148130
os::EXE_SUFFIX))
149131
}
150132
}
151-
152-
#[cfg(test)]
153-
mod test {
154-
use core::os;
155-
156-
#[test]
157-
fn recursive_mkdir_ok() {
158-
let root = os::tmpdir();
159-
let path = "xy/z/zy";
160-
let nested = root.push(path);
161-
assert!(super::mkdir_recursive(&nested));
162-
assert!(os::path_is_dir(&root.push("xy")));
163-
assert!(os::path_is_dir(&root.push("xy/z")));
164-
assert!(os::path_is_dir(&nested));
165-
}
166-
}

trunk/src/rt/rust_env.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ get_max_stk_size() {
9797
return strtol(maxsz, NULL, 0);
9898
}
9999
else {
100-
return 1024*1024*1024;
100+
return 1024*1024*8;
101101
}
102102
}
103103

trunk/src/rt/rust_task.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,11 @@ rust_task::new_stack(size_t requested_sz) {
530530
// arbitrarily selected as 2x the maximum stack size.
531531
if (!unwinding && used_stack > max_stack) {
532532
LOG_ERR(this, task, "task %" PRIxPTR " ran out of stack", this);
533-
abort();
533+
fail();
534534
} else if (unwinding && used_stack > max_stack * 2) {
535535
LOG_ERR(this, task,
536536
"task %" PRIxPTR " ran out of stack during unwinding", this);
537-
abort();
537+
fail();
538538
}
539539

540540
size_t sz = rust_stk_sz + RED_ZONE_SIZE;

trunk/src/test/run-fail/issue-2144.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern:ran out of stack
12+
13+
// Don't leak when the landing pads need to request more stack
14+
// than is allowed during normal execution
15+
16+
fn useBlock(f: ~fn() -> uint) { useBlock(|| 22u ) }
17+
fn main() {
18+
useBlock(|| 22u );
19+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-test iloops with optimizations on
12+
13+
// NB: Not sure why this works. I expect the box argument to leak when
14+
// we run out of stack. Maybe the box annihilator works it out?
15+
16+
// error-pattern:ran out of stack
17+
fn main() {
18+
eat(@0);
19+
}
20+
21+
fn eat(
22+
+a: @int
23+
) {
24+
eat(a)
25+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-test
12+
// error-pattern:ran out of stack
13+
fn main() {
14+
eat(~0);
15+
}
16+
17+
fn eat(
18+
+a: ~int
19+
) {
20+
eat(a)
21+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern:ran out of stack
12+
13+
// Test that the task fails after hiting the recursion limit
14+
15+
fn main() {
16+
debug!(~"don't optimize me out");
17+
main();
18+
}

0 commit comments

Comments
 (0)