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

Assertion "! ctx->ready_is_linked()" when using condition_variable::wait_for #128

Closed
m0xf opened this issue Jun 2, 2017 · 1 comment
Closed

Comments

@m0xf
Copy link

m0xf commented Jun 2, 2017

When i use condition_variable::wait_for in multipliy fibers program crashes with assertion:
"Assertion failed: ! ctx->ready_is_linked(), file libs\fiber\src\scheduler.cpp, line 192".

Minimal sample:

#include <boost/fiber/all.hpp>
#include <mutex>
#include <thread>
#include <chrono>

int main()
{
    boost::fibers::condition_variable condvar;
    boost::fibers::mutex mutex;

    auto do_work = [&]()
    {
        while (true)
        {
            {
                std::unique_lock<boost::fibers::mutex> lock(mutex);
                condvar.wait_for(lock, std::chrono::milliseconds(50));
            }
            //emulate some calculations
            std::this_thread::sleep_for(std::chrono::milliseconds(5));
        }
    };

    boost::fibers::fiber fiber1(do_work);
    boost::fibers::fiber fiber2(do_work);
    boost::fibers::fiber fiber3(do_work);
    boost::fibers::fiber fiber4(do_work);
    boost::fibers::fiber fiber5(do_work);
    boost::fibers::fiber fiber6(do_work);

    boost::fibers::fiber fiber([&]()
    {
        while (true)
        {
            {
                std::lock_guard<boost::fibers::mutex> lock(mutex);
                condvar.notify_one();
            }
            boost::this_fiber::sleep_for(std::chrono::milliseconds(10));
        }
    });
    fiber.join();
    return 0;
}

Compiler msvc-14.0, windows 7.

olk added a commit that referenced this issue Jun 3, 2017
- in context of #128
- if a blocking op. timed out, the context must be removed
  from the waiting-queue of the object
@olk
Copy link
Member

olk commented Jun 3, 2017

ty - fixed

@olk olk closed this as completed Jun 3, 2017
Romain-Geissler-1A pushed a commit to Romain-Geissler-1A/fiber that referenced this issue Apr 3, 2020
Mark 32-bit GNU assembly files targeting Windows as safeseh compatible
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