Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking issue for async/await in Kani (feature async-lib) #1393

Open
4 of 8 tasks
fzaiser opened this issue Jul 19, 2022 · 0 comments
Open
4 of 8 tasks

Tracking issue for async/await in Kani (feature async-lib) #1393

fzaiser opened this issue Jul 19, 2022 · 0 comments
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature. T-TrackingIssue Issues used to track a large amount of work related to a feature

Comments

@fzaiser
Copy link
Contributor

fzaiser commented Jul 19, 2022

Requested feature: async/await
Use case: to support popular libraries like tokio
Link to relevant documentation (Rust reference, Nomicon, RFC):

Test case
use std::{
    future::Future,
    pin::Pin,
    task::{Context, RawWaker, RawWakerVTable, Waker},
};

#[kani::proof]
fn main() {
    let result = block_on(async { 42 }, 1);
    assert_eq!(result, Some(42));
}

fn block_on<F: Future>(mut fut: F, limit: usize) -> Option<<F as Future>::Output> {
    let waker = unsafe { Waker::from_raw(NOOP_RAW_WAKER) };
    let cx = &mut Context::from_waker(&waker);
    for _ in 0..limit {
        let pinned = unsafe { Pin::new_unchecked(&mut fut) };
        match pinned.poll(cx) {
            std::task::Poll::Ready(res) => return Some(res),
            std::task::Poll::Pending => continue,
        }
    }
    None
}

const NOOP_RAW_WAKER: RawWaker = {
    unsafe fn clone_waker(_: *const ()) -> RawWaker {
        NOOP_RAW_WAKER
    }
    unsafe fn wake(_: *const ()) {}
    unsafe fn wake_by_ref(_: *const ()) {}
    unsafe fn drop_waker(_: *const ()) {}
    RawWaker::new(
        std::ptr::null(),
        &RawWakerVTable::new(clone_waker, wake, wake_by_ref, drop_waker),
    )
};

Progress

This issue is to track progress on the implementation:

@fzaiser fzaiser self-assigned this Jul 19, 2022
@fzaiser fzaiser changed the title Support async/await in Kani Implementation plan for async/await in Kani Aug 11, 2022
@rahulku rahulku added the [C] Feature / Enhancement A new feature request or enhancement to an existing feature. label Sep 22, 2023
@celinval celinval changed the title Implementation plan for async/await in Kani Tracking issue for async/await in Kani (feature async-lib) Sep 22, 2023
@celinval celinval added the T-TrackingIssue Issues used to track a large amount of work related to a feature label Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature. T-TrackingIssue Issues used to track a large amount of work related to a feature
Projects
No open projects
Status: In Progress
Development

No branches or pull requests

3 participants