Weird infinite loop when cv.notify_all()
HardLaugh opened this issue · 3 comments
First of all, this is a very powerful library, regret having not met earlier
follow the tutorial, start multiple threads, use condition variables to wait for finish. a strange thing happened, when main thread signal(cv.notify_all()) terminate, there was a chance (It's about 100 repetitions, maybe once) of an infinite loop. some threads(not all) stuck on pick_next function, but has no work todo. change cv.wait(lk) to cv.wait(lk, pred), strange things disappear.Is there any possible explanation?
boost version: 1.82
Synchronization: boost::fibers::mutex and boost::fibers::condition_variable
One more question.In multi-thread scenarios, i think the exit should be synchronized with the main thread. Otherwise, some remote scheduler may have been destructed, last worker try to remote notify( heap-use-after-free detected
by asan
),
possible ways:
- thread_barriers
- main thread should hold lock to finish notify_all ??
Under multi-thread stress testing, there are many problems with stable use. Is there a better official best practice?
done, I had to isolate a separate fiber environment, so I made a lot of the basic components myself