You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extended usage of the thread_pool library causes odd quirks. Particularly, the call wait_for_tasks() crashes when paired with the submit() and storing into a std::vector of std::future(s). I have not been able to replicate beyond the fact it occurs in the same test. I have tried replicating the issue to no avail with similar calls. Unless an edge case has been missed in my unit tests (likely, but probably not), the call itself crashes as the function passes through without issue with similar parameter specifications.
Minimal working example
Short of giving you my source code for my project, there is not much. Submit some tasks with the std::future(s) stuffed into a std::vector. Call wait_for_tasks(). Then I have a section of code for accessing the values in the futures.
Behavior
Conjoined usage of the wait_for_tasks() and submit().
System information
CPU model, architecture, # of cores and threads: i7-10875H x 16
Operating system: Ubuntu 21.10
Name and version of C++ compiler: gcc 11.2
Full command used for compiling, including all compiler flags: Bazel's -c opt and C++20 specified
Thread pool library version: latest
(Please note that only the latest version of the thread pool library is supported.)
Additional information
I did some digging into the source code. There are a lot of C-Style casts amongst other bits and pieces that lead to undefined behavior. At one point, I went so far as to strip out everything but the code itself to see what was going on (lots of noise otherwise). No luck.
My best guess is either a cast is failing (unlikely, but maybe) or a race condition exists within the logic of the submit() and/or wait_for_tasks().
The text was updated successfully, but these errors were encountered:
J-B-Blankenship
changed the title
[BUG] wait_for_tasks() Segmentation Faults in Conjunction with submit_task()
[BUG] wait_for_tasks() Segmentation Faults in Conjunction with submit()
Mar 24, 2022
Thanks for the bug report. Many people, including myself, are using this thread pool in a variety of complex scenarios, and have not encountered the issues you are describing. So unless you provide a minimal working example that reproduces this bug, there's nothing I can do.
Also, there's nothing wrong with C-style casts, their behavior is well-defined. I do agree that using C++ cast expressions is clearer, but I don't see why the C-style casts used in the library would lead to any bugs or ill-defined behavior.
My application was frequently (but now always) crashing with a Segmentation Fault, when wait_for_tasks was invoked on a separate thread. In this case, the thread was launched using std::async(std::launch::async, my_function)
Moving the wait_for_tasks invocation to the application's main thread solved the problem for me.
Thanks for letting me know. Mixing std::async with BS::thread_pool is not recommended; instead, consider using only BS::thread_pool, or perhaps two BS::thread_pools. If you are still having issues, please open a new issue with a minimal working example and I will look into it.
Describe the bug
Extended usage of the thread_pool library causes odd quirks. Particularly, the call wait_for_tasks() crashes when paired with the submit() and storing into a std::vector of std::future(s). I have not been able to replicate beyond the fact it occurs in the same test. I have tried replicating the issue to no avail with similar calls. Unless an edge case has been missed in my unit tests (likely, but probably not), the call itself crashes as the function passes through without issue with similar parameter specifications.
Minimal working example
Short of giving you my source code for my project, there is not much. Submit some tasks with the std::future(s) stuffed into a std::vector. Call wait_for_tasks(). Then I have a section of code for accessing the values in the futures.
Behavior
Conjoined usage of the wait_for_tasks() and submit().
System information
(Please note that only the latest version of the thread pool library is supported.)
Additional information
I did some digging into the source code. There are a lot of C-Style casts amongst other bits and pieces that lead to undefined behavior. At one point, I went so far as to strip out everything but the code itself to see what was going on (lots of noise otherwise). No luck.
My best guess is either a cast is failing (unlikely, but maybe) or a race condition exists within the logic of the submit() and/or wait_for_tasks().
The text was updated successfully, but these errors were encountered: