Skip to content

Commit fe9929e

Browse files
committed
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.
2 parents 20454da + 7bd6a92 commit fe9929e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/librust/rust.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ struct Command<'self> {
6060
usage_full: UsageSource<'self>,
6161
}
6262

63-
static COMMANDS: &'static [Command<'static>] = &[
63+
static NUM_OF_COMMANDS: uint = 7;
64+
65+
// FIXME(#7617): should just be &'static [Command<'static>]
66+
// but mac os doesn't seem to like that and tries to loop
67+
// past the end of COMMANDS in usage thus passing garbage
68+
// to str::repeat and eventually malloc and crashing.
69+
static COMMANDS: [Command<'static>, .. NUM_OF_COMMANDS] = [
6470
Command{
6571
cmd: "build",
6672
action: CallMain("rustc", rustc::main),

0 commit comments

Comments
 (0)