From 797d0408a91c0ea426012130bcac075eb4059ade Mon Sep 17 00:00:00 2001 From: Maksym Vorobiov Date: Tue, 28 Jan 2020 19:08:03 +0300 Subject: [PATCH] add test crashing with segfault according to #1321 --- actix-http/src/body.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/actix-http/src/body.rs b/actix-http/src/body.rs index 1a2428e14d0..1c34b06a074 100644 --- a/actix-http/src/body.rs +++ b/actix-http/src/body.rs @@ -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() { @@ -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 {