Hi Boost developers,
I'm having a problem with passing a completion function to a
boost::barrier, causing a segfault, and I suspect it is a bug in the
barrier code. The following is a minimal example that shows the problem:
#include
void func(int)
{
}
int main()
{
boost::barrier b(1, std::bind(func, 42));
b.wait();
}
Running inside gdb and doing a bt shows some infinite recursion
happening, starting with:
#0 0x000055555555e41a in
boost::thread_detail::decay_copy&>(boost::detail::nullary_function&) (
t=) at /usr/include/boost/thread/detail/move.hpp:355
#1 0x000055555555d814 in boost::detail::nullary_function::nullary_function&>(boost::detail::nullary_function&) (
this=0x7fffff7ff0c0, f=...) at
/usr/include/boost/thread/detail/nullary_function.hpp:81
...
When I change "std::bind(func, 42)" to just "func" (and declare func
without parameters), it does work and the program exits normally.
Passing a lambda to barrier (e.g. barrier(1, [&]() { func(0); } ) )
causes the same segfault, and the same holds when I change std::bind to
boost::bind. I'm using Boost 1.67 on Debian Linux, amd64, gcc 8.2.0. Is
this a bug?
Cheers,
André