Subject: [Boost-bugs] [Boost C++ Libraries] #4894: segmentation fault on thread_group::join_all depending on the machine used
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-11-25 08:31:00
#4894: segmentation fault on thread_group::join_all depending on the machine used
--------------------------------+-------------------------------------------
Reporter: lyxthe@⦠| Owner:
Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
Version: Boost 1.35.0 | Severity: Problem
Keywords: |
--------------------------------+-------------------------------------------
Hello I would like to submit this new ticket, hopping it is really a
problem and not an error of my own.
I explain the problem, I made this simple program (just after) and,
depending on the machine where I execute it, it makes a segmentation fault
or not. I would like to know if it is because of the computer used or if
it is really a bug.
The program :
{{{
#include <iostream>
#include <boost/thread/thread.hpp>
#include <boost/bind.hpp>
using namespace std;
const int thread_nbr=20;
void fonct(int num){
cout << "thread " << num << endl;
}
int main(){
int i=0;
int j=0;
boost::thread_group groupe;
for(i=0;i<5;i++){
cout << "beginning of loop " << i << ":" << endl;
for(j=1;j<thread_nbr;j++){
groupe.create_thread(boost::bind(fonct,j));
}
fonct(0);
cout << "after fonct" << endl;
cout << "waiting for join.all" << endl;
groupe.join_all();
cout << "after join.all" << endl << endl;
}
return 0;
}
}}}
The trace when it works (I have tested it on five different computers, one
with one core, one with two cores, two with four cores, one with twelve
cores, it didn't work for the one with twelve and one with four) :
{{{
beginning of loop 0:
thread 1
thread 2
thread 3
thread 4
thread 5
thread 6
thread 7
thread 8
thread 9
thread 10
thread 11
thread 12
thread 13
thread 14
thread 15
thread 16
thread 17
thread 18
thread 19
thread 0
after fonct
waiting for join.all
after join.all
beginning of loop 1:
thread 1
thread 2
thread 3
thread 4
thread 5
thread 6
thread 7
thread 8
thread 9
thread 10
thread 11
thread 12
thread 13
thread 14
thread 15
thread 16
thread 17
thread 18
thread 19
thread 0
after fonct
waiting for join.all
Segmentation fault
}}}
On the other situations it works until the end.
If I put the "const int thread_nbr" to 4 instead of 20, it works on every
machine I tried.
Apparently the problem come from the thread_group::join_all() function.
Could the thread_group make a problem on certain machines when the number
of threads in the group is big ?
I Have tested it with boost 1.35 and boost 1.42.
Do you know where the problem can come from.
Is it a known problem maybe already solved in newer version of boost?
Thanks to care on my question, and sorry for my bad english.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4894> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC