Boost C++ Libraries: Ticket #5150: boost::thread does not print or return the error value when creating a thread fails. https://svn.boost.org/trac10/ticket/5150 <p> I'm running on Win7 64bit Professional, and building 32-bit code on MSVC2008. </p> <p> For some reason, I'm getting boost::thread_resource_error from void thread::start_thread() in <a class="ext-link" href="http://svn.boost.org/svn/boost/trunk/libs/thread/src/win32/thread.cpp"><span class="icon">​</span>http://svn.boost.org/svn/boost/trunk/libs/thread/src/win32/thread.cpp</a> , but I'm unable to debug this issue, since the boost sources don't check for the error value of when this call fails. </p> <p> <a class="ext-link" href="http://msdn.microsoft.com/en-us/library/kdzttdcb(v=vs.80).aspx"><span class="icon">​</span>http://msdn.microsoft.com/en-us/library/kdzttdcb(v=vs.80).aspx</a> specifies that _beginthreadex returns 0 on an error, in which case errno and _doserrno are set. </p> <p> Expected: The value of errno is caught in the code and passed in the exception so that the client can debug the reason of the failure. </p> <p> (The following background for some context, although it's such a voodoo situation I can not report that as a bug directly, better start with the above first) </p> <p> My code that uses boost threads worked ok previously, and curiously it was that incorporating the use of QScriptEngineDebugger from Qt 4.6 into my application started exhibiting this problem. If I remove the use of QScriptEngineDebugger, the thread is created fine. I am using less than 100MB of memory, and my application is running about 15 threads, so it shouldn't be a system resource consumption issue. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5150 Trac 1.4.3 viboes Tue, 10 May 2011 21:48:56 GMT <link>https://svn.boost.org/trac10/ticket/5150#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5150#comment:1</guid> <description> <p> Please, could you clarify what is exactly wrong with the library? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 11 May 2011 07:04:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5150#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5150#comment:2</guid> <description> <p> The problem is that the boost sources don't check for the error value when it creates a new thread in thread.cpp and report it back in any way, which makes it impossible to debug the reason why a thread creation might fail. </p> <p> The thread::start_thread() calls _beginthreadex (which calls <a class="missing wiki">CreateThread</a> if BOOST_HAS_THREADEX isn't defined). <a class="missing wiki">CreateThread</a> has the following documentation on MSDN: "If the function fails, the return value is NULL. To get extended error information, call <a class="missing wiki">GetLastError</a>." _beginthreadex has the following documentation on MSDN: "_beginthreadex returns 0 on an error, in which case errno and _doserrno are set.". </p> <p> It would be more helpful if the the exception "boost::throw_exception(thread_resource_error());" would carry the reason for the failure, instead of only reporting back "I failed for an unknown reason.". </p> <p> I tried to manually read <a class="missing wiki">GetLastError</a> when this occurred, but it returned 0, which indicates that the error field was cleared by an operation in between. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 04 Dec 2011 00:33:52 GMT</pubDate> <title>type, severity changed https://svn.boost.org/trac10/ticket/5150#comment:3 https://svn.boost.org/trac10/ticket/5150#comment:3 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Feature Requests</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Not Applicable</span> </li> </ul> <p> I don't see any bug in Boost.Thread. I think your concern will be best managed as a feature request. </p> Ticket viboes Wed, 07 Dec 2011 00:11:16 GMT status changed; resolution set; milestone deleted https://svn.boost.org/trac10/ticket/5150#comment:4 https://svn.boost.org/trac10/ticket/5150#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">duplicate</span> </li> <li><strong>milestone</strong> <span class="trac-field-deleted">To Be Determined</span> </li> </ul> <p> I have think a little bit more about this issue and I think that following the standard C++11 would respond to your request. I have added a more explicit feature request </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6230" title="#6230: Tasks: Follows the exception reporting mechanism as defined in the c++11 (closed: fixed)">#6230</a> Follows the exception reporting mechanism as defined in the c++11 </p> <p> So I will close this feature as duplicated. </p> Ticket