about summary refs log tree commit diff
path: root/src/libsync
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-08-27 19:46:14 +0000
committerbors <bors@rust-lang.org>2014-08-27 19:46:14 +0000
commitf2b87e9ff0ffa1e08556bf8f41058f1caeb99ac6 (patch)
tree8448accce1061fcbb83aa5b9fbdb3d439ad04b48 /src/libsync
parent3ee047ae1ffab454270bc1859b3beef3556ef8f9 (diff)
parent5c82f484db29e37e26064e853d8a303cc13bc78c (diff)
downloadrust-f2b87e9ff0ffa1e08556bf8f41058f1caeb99ac6.tar.gz
rust-f2b87e9ff0ffa1e08556bf8f41058f1caeb99ac6.zip
auto merge of #16797 : nikomatsakis/rust/remove-invalid-spsc_queue-test, r=alexcrichton
This test seems to read freed memory -- the peeked variable points into the queue, but then the pop operation removes the node from the queue and moves the enclosing `T` elsewhere, invalidating the `peeked` pointer.

r? @alexcrichton 
Diffstat (limited to 'src/libsync')
-rw-r--r--src/libsync/spsc_queue.rs21
1 files changed, 0 insertions, 21 deletions
diff --git a/src/libsync/spsc_queue.rs b/src/libsync/spsc_queue.rs
index 578e518cb8f..32b77be78a4 100644
--- a/src/libsync/spsc_queue.rs
+++ b/src/libsync/spsc_queue.rs
@@ -315,27 +315,6 @@ mod test {
         assert_eq!(consumer.pop(), None);
     }
 
-    // This behaviour is blocked by the type system if using the safe constructor
-    #[test]
-    fn pop_peeked_unchecked() {
-        let q = unsafe { Queue::new(0) };
-        q.push(vec![1i]);
-        q.push(vec![2]);
-        let peeked = q.peek().unwrap();
-
-        assert_eq!(*peeked, vec![1]);
-        assert_eq!(q.pop(), Some(vec![1]));
-
-        assert_eq!(*peeked, vec![1]);
-        q.push(vec![7]);
-
-        // Note: This should actually expect 1, but this test is to highlight
-        // the unsafety allowed by the unchecked usage. A Rust user would not
-        // expect their peeked value to mutate like this without the type system
-        // complaining.
-        assert_eq!(*peeked, vec![7]);
-    }
-
     #[test]
     fn peek() {
         let (mut consumer, mut producer) = queue(0);