[Boost-bugs] [Boost C++ Libraries] #8443: Header file inclusion order may cause crashes

Subject: [Boost-bugs] [Boost C++ Libraries] #8443: Header file inclusion order may cause crashes
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-04-15 22:47:38


#8443: Header file inclusion order may cause crashes
-----------------------------------------------------------------+----------
 Reporter: Nathan Crookston <nathan.crookston+boost@…> | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
  Version: Boost Release Branch | Severity: Problem
 Keywords: |
-----------------------------------------------------------------+----------
 pthread/mutex.hpp and pthread/recursive_mutex.hpp both attempt to define
 the macro BOOST_PTHREAD_HAS_TIMEDLOCK. They each have different
 conditions for when to define it, which results in different cpp files
 thinking certain objects are different sizes, and it (hopefully) crashes.

 While it would be good to provide logic for defining the symbol in one
 place (mutex.hpp was most recently updated for #3639), I believe that both
 conditions are wrong:

 {{{#!c++
 #ifdef _POSIX_TIMEOUTS
 #if _POSIX_TIMEOUTS >= 0
 #define BOOST_PTHREAD_HAS_TIMEDLOCK
 #endif
 #endif
 }}}
 and
 {{{#!c++
 #ifdef _POSIX_TIMEOUTS
 #if _POSIX_TIMEOUTS >= 0 && _POSIX_C_SOURCE>=200112L
 #define BOOST_PTHREAD_HAS_TIMEDLOCK
 #endif
 #endif
 }}}

 I think using _POSIX_C_SOURCE is not right. On our platform (solaris
 variant), _POSIX_C_SOURCE == 199506L, but _POSIX_TIMEOUTS == 200112L and
 pthread_mutex_timedlock is available.

 Thus, I suggest using the following for both conditions (and hopefully
 testing the condition in one place):

 {{{#!c++
 #if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 200112L
 #define BOOST_PTHREAD_HAS_TIMEDLOCK
 #endif
 }}}

 This problem is in trunk starting with at least 1.49, and remains in the
 current version, as well as trunk.

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