Skip to content

Commit d0e4571

Browse files
committed
---
yaml --- r: 127353 b: refs/heads/master c: 4ed40ff h: refs/heads/master i: 127351: bb09745 v: v3
1 parent 3938215 commit d0e4571

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1138
-294
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: e59fb9eb628d5c2242568731396259bf02d50768
2+
refs/heads/master: 4ed40ffe8ebbb4479f48af59781d9cf7dcc359da
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 12e0f72f517516ac4fce2aed85e6142e9b874bce
55
refs/heads/try: 850af8feebe925207829017f837be826401d71a7

trunk/CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ please do two things:
1616

1717
2. Run the full Rust test suite with the `make check` command. You're
1818
not off the hook even if you just stick to documentation; code
19-
examples in the docs are tested as well!
19+
examples in the docs are tested as well! Although for simple
20+
wording or grammar fixes, this is probably unnecessary.
2021

2122
Pull requests will be treated as "review requests", and we will give
2223
feedback we expect to see corrected on

trunk/src/libcollections/ringbuf.rs

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,11 @@ impl<'a, T> ExactSize<&'a mut T> for MutItems<'a, T> {}
403403
fn grow<T>(nelts: uint, loptr: &mut uint, elts: &mut Vec<Option<T>>) {
404404
assert_eq!(nelts, elts.len());
405405
let lo = *loptr;
406-
let newlen = nelts * 2;
407-
elts.reserve(newlen);
406+
elts.reserve(nelts * 2);
407+
let newlen = elts.capacity();
408408

409409
/* fill with None */
410-
for _ in range(elts.len(), elts.capacity()) {
410+
for _ in range(elts.len(), newlen) {
411411
elts.push(None);
412412
}
413413

@@ -750,6 +750,47 @@ mod tests {
750750
assert_eq!(d.len(), 1);
751751
}
752752

753+
#[test]
754+
fn test_with_capacity_non_power_two() {
755+
let mut d3 = RingBuf::with_capacity(3);
756+
d3.push(1i);
757+
758+
// X = None, | = lo
759+
// [|1, X, X]
760+
assert_eq!(d3.pop_front(), Some(1));
761+
// [X, |X, X]
762+
assert_eq!(d3.front(), None);
763+
764+
// [X, |3, X]
765+
d3.push(3);
766+
// [X, |3, 6]
767+
d3.push(6);
768+
// [X, X, |6]
769+
assert_eq!(d3.pop_front(), Some(3));
770+
771+
// Pushing the lo past half way point to trigger
772+
// the 'B' scenario for growth
773+
// [9, X, |6]
774+
d3.push(9);
775+
// [9, 12, |6]
776+
d3.push(12);
777+
778+
d3.push(15);
779+
// There used to be a bug here about how the
780+
// RingBuf made growth assumptions about the
781+
// underlying Vec which didn't hold and lead
782+
// to corruption.
783+
// (Vec grows to next power of two)
784+
//good- [9, 12, 15, X, X, X, X, |6]
785+
//bug- [15, 12, X, X, X, |6, X, X]
786+
assert_eq!(d3.pop_front(), Some(6));
787+
788+
// Which leads us to the following state which
789+
// would be a failure case.
790+
//bug- [15, 12, X, X, X, X, |X, X]
791+
assert_eq!(d3.front(), Some(&9));
792+
}
793+
753794
#[test]
754795
fn test_reserve_exact() {
755796
let mut d = RingBuf::new();

trunk/src/libcore/num/f32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ impl Float for f32 {
293293
#[inline]
294294
fn frac_pi_8() -> f32 { consts::FRAC_PI_8 }
295295

296-
/// 1 .0/ pi
296+
/// 1.0 / pi
297297
#[inline]
298298
fn frac_1_pi() -> f32 { consts::FRAC_1_PI }
299299

trunk/src/librustc/back/link.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,20 @@ fn link_args(cmd: &mut Command,
14001400
cmd.arg("-Wl,--gc-sections");
14011401
}
14021402

1403+
let used_link_args = sess.cstore.get_used_link_args().borrow();
1404+
1405+
// Dynamically linked executables can be compiled as position independent if the default
1406+
// relocation model of position independent code is not changed. This is a requirement to take
1407+
// advantage of ASLR, as otherwise the functions in the executable are not randomized and can
1408+
// be used during an exploit of a vulnerability in any code.
1409+
if sess.targ_cfg.os == abi::OsLinux {
1410+
let mut args = sess.opts.cg.link_args.iter().chain(used_link_args.iter());
1411+
if !dylib && sess.opts.cg.relocation_model.as_slice() == "pic" &&
1412+
!args.any(|x| x.as_slice() == "-static") {
1413+
cmd.arg("-pie");
1414+
}
1415+
}
1416+
14031417
if sess.targ_cfg.os == abi::OsLinux || sess.targ_cfg.os == abi::OsDragonfly {
14041418
// GNU-style linkers will use this to omit linking to libraries which
14051419
// don't actually fulfill any relocations, but only for libraries which
@@ -1568,9 +1582,7 @@ fn link_args(cmd: &mut Command,
15681582
// Finally add all the linker arguments provided on the command line along
15691583
// with any #[link_args] attributes found inside the crate
15701584
cmd.args(sess.opts.cg.link_args.as_slice());
1571-
for arg in sess.cstore.get_used_link_args().borrow().iter() {
1572-
cmd.arg(arg.as_slice());
1573-
}
1585+
cmd.args(used_link_args.as_slice());
15741586
}
15751587

15761588
// # Native library linking

0 commit comments

Comments
 (0)