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

Sporadic Deadlock When Using Async and Yield #90

Open
Jason-KChen opened this issue Aug 25, 2020 · 2 comments
Open

Sporadic Deadlock When Using Async and Yield #90

Jason-KChen opened this issue Aug 25, 2020 · 2 comments

Comments

@Jason-KChen
Copy link

I am running into a possible deadlock scenario when running the attached code without HCLIB_LOCALITY_FILE and with two workers.

The promises and waits were executed just fine but it seems like the tasks themselves never finish for some reason. I am able to reproduce this issue about 7 out of 10 runs on my machine. @srirajpaul was also able to reproduce this.

#include <chrono>
#include <cstdint>
#include <iostream>
#include <stdlib.h>
#include <thread>

#include "hclib_cpp.h"

int main(int argc, char** argv) {
    const char* deps[] = { "system" };
    hclib::launch(deps, 1, []() {
        hclib::finish([]() {
            hclib::async([]() {
                hclib::promise_t<int>* x = new hclib::promise_t<int>();
                hclib::promise_t<int>* y = new hclib::promise_t<int>();

                hclib::async([y] {
                    hclib::yield();
                    y->put(1);
                });

                hclib::async([x] {
                    x->get_future()->wait();
                });

                y->get_future()->wait();
                x->put(10);
            });
        });
        std::cout << "all finished " << std::endl;
    });
    return 0;
}
@Jason-KChen Jason-KChen changed the title Sporadic Deadlock when using async and yield Sporadic Deadlock When Using Async and Yield Aug 25, 2020
@agrippa
Copy link
Contributor

agrippa commented Aug 26, 2020

@JKChenFZ I'm seeing sporadic hangs in some of our other tests as well (cpp/promise/async_future_await_at) that use put and wait. I'm working on finding when the issue was introduced, but at the moment I'm all the way back to this commit and the issue still exists:

commit 01aafbf
Merge: ae2801e bfff5c4
Author: Max Grossman [email protected]
Date: Sun May 17 09:28:25 2020 -0700

Merge pull request #83 from habanero-rice/access_promise_from_future

Some new async APIs, small formatting and comments changes

Just wanted to say thanks for calling this out, and let you know I'm looking in to it.

@agrippa
Copy link
Contributor

agrippa commented Aug 26, 2020

I suspect this may be the same issue as:

#73

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants