Skip to content

Commit

Permalink
add test crashing with segfault according to #1321
Browse files Browse the repository at this point in the history
  • Loading branch information
dunnock authored and JohnTitor committed Feb 27, 2020
1 parent 48ef4d7 commit a4148de
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions actix-http/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,8 @@ mod tests {

mod body_stream {
use super::*;
use futures::task::noop_waker;
use futures::stream::once;

#[actix_rt::test]
async fn skips_empty_chunks() {
Expand All @@ -629,6 +631,25 @@ mod tests {
Some(Bytes::from("2")),
);
}

#[actix_rt::test]
async fn move_pinned_pointer() {
let (sender, receiver) = futures::channel::oneshot::channel();
let mut body_stream = Ok(BodyStream::new(once(async {
let x = Box::new(0i32);
let y = &x;
receiver.await.unwrap();
let _z = **y;
Ok::<_, ()>(Bytes::new())
})));

let waker = noop_waker();
let mut context = Context::from_waker(&waker);

let _ = body_stream.as_mut().unwrap().poll_next(&mut context);
sender.send(()).unwrap();
let _ = std::mem::replace(&mut body_stream, Err([0; 32])).unwrap().poll_next(&mut context);
}
}

mod sized_stream {
Expand Down

0 comments on commit a4148de

Please sign in to comment.