Re: [Boost-bugs] [Boost C++ Libraries] #9355: boost::coroutine crash in base<void>::pull_coroutine_base<void> with multiple threads

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9355: boost::coroutine crash in base<void>::pull_coroutine_base<void> with multiple threads
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-11-13 08:17:04


#9355: boost::coroutine crash in base<void>::pull_coroutine_base<void> with
multiple threads
-------------------------------+----------------------------------------
  Reporter: craig@… | Owner: olli
      Type: Bugs | Status: reopened
 Milestone: To Be Determined | Component: coroutine
   Version: Boost 1.55.0 | Severity: Problem
Resolution: | Keywords: pull_coroutine_base; crash
-------------------------------+----------------------------------------
Changes (by Craig Hutchinson <craig@…>):

 * status: closed => reopened
 * resolution: worksforme =>

Comment:

 I have been drilling down into the code and have located the offending
 problem in standard_stack_allocator_windows.cpp @ line 63:

 {{{
 SYSTEM_INFO system_info()
 {
     static SYSTEM_INFO si = system_info_();
     return si;
 }
 }}}

 This function is called in standard_stack_allocator::allocate(...) via
 detail::pagesize(). The issue here is the use of a static variable in an
 unsafe manner between threads which explains why it might only fall over
 the first time and then run without fail.

 The first thread is initializing the static value and writing to the
 structure. A second thread is then already reading/read data from it. This
 means pagesize() is returning an uninitialized variable.

 I don't know the performance characteristics of GetSystemInfo() but a very
 simple work-around for the crashes is to remove the 'static' keyword:

 {{{
 /*static*/ SYSTEM_INFO si = system_info_();
 }}}

 A better solution is a critical section though as GetSystemInfo() may take
 an unkown time which I think is the root to the issue to begin with.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9355#comment:12>
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:14 UTC