-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from yoshuawuyts/fix-ub
Fix #155
- Loading branch information
Showing
11 changed files
with
112 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//! Regression test for: https://github.com/yoshuawuyts/futures-concurrency/issues/155 | ||
//! | ||
//! We accidentally were marking a value as "ready" in `try_join`on the error | ||
//! path. This meant that when we returned, the destructor assumed a value was | ||
//! initialized when it wasn't, causing it to dereference uninitialized memory. | ||
use futures_concurrency::prelude::*; | ||
use futures_core::Future; | ||
use std::{future::ready, pin::Pin}; | ||
use tokio::time::{sleep, Duration}; | ||
|
||
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>; | ||
|
||
async fn process_not_fail() -> Result<Vec<i32>, ()> { | ||
sleep(Duration::from_millis(100)).await; | ||
Ok(vec![ready(1), ready(2)].join().await) | ||
} | ||
|
||
async fn process_fail() -> Result<Vec<i32>, ()> { | ||
Err(()) | ||
} | ||
|
||
#[tokio::test] | ||
async fn array() { | ||
let a: BoxFuture<'static, _> = Box::pin(process_fail()); | ||
let b: BoxFuture<'static, _> = Box::pin(process_not_fail()); | ||
let res = [a, b].try_join().await; | ||
assert!(res.is_err()); | ||
} | ||
|
||
#[tokio::test] | ||
async fn vec() { | ||
let a: BoxFuture<'static, _> = Box::pin(process_fail()); | ||
let b: BoxFuture<'static, _> = Box::pin(process_not_fail()); | ||
let res = vec![a, b].try_join().await; | ||
assert!(res.is_err()); | ||
} | ||
|
||
#[tokio::test] | ||
async fn tuple() { | ||
let a = process_fail(); | ||
let b = process_not_fail(); | ||
let res = (a, b).try_join().await; | ||
assert!(res.is_err()); | ||
} |
This file was deleted.
Oops, something went wrong.