about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-07-28 02:07:27 -0700
committerbors <bors@rust-lang.org>2013-07-28 02:07:27 -0700
commitfe9929e303f4e0322fd0f38ec6cb6b3ec932e4a3 (patch)
treec3cdc7f7bcd73aa617d1ce5a408a9c4fb2d67439
parent20454da2db9903688dfd60b826cc704de79767bc (diff)
parent7bd6a92a5a73be334f09791bbc3c83468b10410c (diff)
downloadrust-fe9929e303f4e0322fd0f38ec6cb6b3ec932e4a3.tar.gz
rust-fe9929e303f4e0322fd0f38ec6cb6b3ec932e4a3.zip
auto merge of #8086 : luqmana/rust/rhelp, r=Aatch
#7617 

While the code that was there should've been perfectly fine (and seemingly is on linux at least) there seems to be some sort of weird interaction going on with statics and vectors. I couldn't get a smaller test case to reproduce that behaviour. The for loop in `rust::usage` seemingly just goes past the end of the vector thus getting garbage which it tries to pass to malloc somewhere down the line.

In any case, using a fixed length vector seems to mitigate this.
-rw-r--r--src/librust/rust.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/librust/rust.rs b/src/librust/rust.rs
index c47c573d16f..746b7529231 100644
--- a/src/librust/rust.rs
+++ b/src/librust/rust.rs
@@ -60,7 +60,13 @@ struct Command<'self> {
     usage_full: UsageSource<'self>,
 }
 
-static COMMANDS: &'static [Command<'static>] = &[
+static NUM_OF_COMMANDS: uint = 7;
+
+// FIXME(#7617): should just be &'static [Command<'static>]
+// but mac os doesn't seem to like that and tries to loop
+// past the end of COMMANDS in usage thus passing garbage
+// to str::repeat and eventually malloc and crashing.
+static COMMANDS: [Command<'static>, .. NUM_OF_COMMANDS] = [
     Command{
         cmd: "build",
         action: CallMain("rustc", rustc::main),