From 5190b5b1e817977994ddb7afd2c27a1a9818236a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 15 Feb 2019 10:41:12 +0100 Subject: [PATCH 1/3] test VecDeque debug printing --- tests/run-pass/vecdeque.rs | 8 ++++++++ tests/run-pass/vecdeque.stdout | 2 ++ 2 files changed, 10 insertions(+) create mode 100644 tests/run-pass/vecdeque.stdout diff --git a/tests/run-pass/vecdeque.rs b/tests/run-pass/vecdeque.rs index 381169505ec..9c9909802e2 100644 --- a/tests/run-pass/vecdeque.rs +++ b/tests/run-pass/vecdeque.rs @@ -9,6 +9,14 @@ fn main() { let mut src = VecDeque::new(); src.push_front(Box::new(2)); dst.append(&mut src); + for a in dst.iter() { + assert_eq!(**a, 2); + } + + // Regression test for Debug and Diaplay impl's + println!("{:?} {:?}", dst, dst.iter()); + println!("{:?}", VecDeque::::new().iter()); + for a in dst { assert_eq!(*a, 2); } diff --git a/tests/run-pass/vecdeque.stdout b/tests/run-pass/vecdeque.stdout new file mode 100644 index 00000000000..63de960ee2b --- /dev/null +++ b/tests/run-pass/vecdeque.stdout @@ -0,0 +1,2 @@ +[2, 2] Iter([2, 2], []) +Iter([], []) From a3eae6c8ab0ac190066c8ebefb0ef0314aa1e7ef Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 15 Feb 2019 10:41:25 +0100 Subject: [PATCH 2/3] collect some bugs that we found --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 21e9fa43a8f..a9e9ee0a1e3 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,18 @@ used according to their aliasing restrictions. [slides]: https://solson.me/miri-slides.pdf [report]: https://solson.me/miri-report.pdf +## Bugs found by Miri + +Miri has already found a number of bugs in the Rust standard library, which we collect here. + +* [`vec_deque::Iter` having an unsound `Debug` implementation](https://github.com/rust-lang/rust/issues/53566) +* [`From<&[T]> for Rc` creating a not sufficiently aligned reference](https://github.com/rust-lang/rust/issues/54908) +* [`BTreeMap` creating a shared reference pointing to a too small allocation](https://github.com/rust-lang/rust/issues/54957) +* [`VecDeque` creating overlapping mutable references](https://github.com/rust-lang/rust/pull/56161) +* [Futures turning a shared reference into a mutable one](https://github.com/rust-lang/rust/pull/56319) +* [`str` turning a shared reference into a mutable one](https://github.com/rust-lang/rust/pull/58200) +* [`BTreeMap` creating mutable references that overlap with shared references](https://github.com/rust-lang/rust/pull/58431) + ## License Licensed under either of From a4c852ddfe95b8726ca4e23f49290f2a561dbd40 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 15 Feb 2019 10:43:27 +0100 Subject: [PATCH 3/3] link to bug list from intro --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a9e9ee0a1e3..897bf0b66e7 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ for example: or an invalid enum discriminant) * WIP: Violations of the rules governing aliasing for reference types +Miri has already discovered some [real-world bugs](#bugs-found-by-miri). + [rust]: https://www.rust-lang.org/ [mir]: https://github.com/rust-lang/rfcs/blob/master/text/1211-mir.md [`unreachable_unchecked`]: https://doc.rust-lang.org/stable/std/hint/fn.unreachable_unchecked.html @@ -256,7 +258,7 @@ used according to their aliasing restrictions. Miri has already found a number of bugs in the Rust standard library, which we collect here. -* [`vec_deque::Iter` having an unsound `Debug` implementation](https://github.com/rust-lang/rust/issues/53566) +* [`Debug for vec_deque::Iter` accessing uninitialized memory](https://github.com/rust-lang/rust/issues/53566) * [`From<&[T]> for Rc` creating a not sufficiently aligned reference](https://github.com/rust-lang/rust/issues/54908) * [`BTreeMap` creating a shared reference pointing to a too small allocation](https://github.com/rust-lang/rust/issues/54957) * [`VecDeque` creating overlapping mutable references](https://github.com/rust-lang/rust/pull/56161)