Boost C++ Libraries: Ticket #4894: segmentation fault on thread_group::join_all depending on the machine used https://svn.boost.org/trac10/ticket/4894 <p> Hello I would like to submit this new ticket, hopping it is really a problem and not an error of my own. </p> <p> 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. </p> <p> The program : </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/thread/thread.hpp&gt; #include &lt;boost/bind.hpp&gt; using namespace std; const int thread_nbr=20; void fonct(int num){ cout &lt;&lt; "thread " &lt;&lt; num &lt;&lt; endl; } int main(){ int i=0; int j=0; boost::thread_group groupe; for(i=0;i&lt;5;i++){ cout &lt;&lt; "beginning of loop " &lt;&lt; i &lt;&lt; ":" &lt;&lt; endl; for(j=1;j&lt;thread_nbr;j++){ groupe.create_thread(boost::bind(fonct,j)); } fonct(0); cout &lt;&lt; "after fonct" &lt;&lt; endl; cout &lt;&lt; "waiting for join.all" &lt;&lt; endl; groupe.join_all(); cout &lt;&lt; "after join.all" &lt;&lt; endl &lt;&lt; endl; } return 0; } </pre><p> 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) : </p> <pre class="wiki">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 </pre><p> On the other situations it works until the end. </p> <p> If I put the "const int thread_nbr" to 4 instead of 20, it works on every machine I tried. </p> <p> Apparently the problem come from the thread_group::join_all() function. </p> <p> Could the thread_group make a problem on certain machines when the number of threads in the group is big ? </p> <p> I Have tested it with boost 1.35 and boost 1.42. </p> <p> Do you know where the problem can come from. </p> <p> Is it a known problem maybe already solved in newer version of boost? </p> <p> Thanks to care on my question, and sorry for my bad english. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4894 Trac 1.4.3 viboes Mon, 29 Nov 2010 15:48:56 GMT component changed; owner set https://svn.boost.org/trac10/ticket/4894#comment:1 https://svn.boost.org/trac10/ticket/4894#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Anthony Williams</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">thread</span> </li> </ul> Ticket viboes Sat, 04 Dec 2010 15:34:44 GMT <link>https://svn.boost.org/trac10/ticket/4894#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4894#comment:2</guid> <description> <p> I have not tried but I see a possible source of the problem: the groupe variable stores threads that are joined several times. Could you try to move the declaration inside the for? </p> <pre class="wiki"> for(i=0;i&lt;5;i++){ boost::thread_group groupe; </pre><p> Vicente </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 08 Dec 2010 09:20:22 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4894#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4894#comment:3</guid> <description> <p> I confirm, if I do like you said, on the two machines where it didn't work, the program runs normally. </p> <p> Well see, problem solved. </p> <p> Thanks </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 04 Dec 2011 00:18:25 GMT</pubDate> <title>status, type changed; resolution set https://svn.boost.org/trac10/ticket/4894#comment:4 https://svn.boost.org/trac10/ticket/4894#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Support Requests</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">worksforme</span> </li> </ul> Ticket