[boost.pool] Workaround for a msvc 7.1 & 8.0 bug surfaced in the boost 1.35 release

Hi all. One of our projects failed to build using the Boost 1.35 release and we traced it down to a compiler bug with MSVC 7.1. & 8.0. We have not tested any earlier compiler versions and MSVB 9.0 seems to have fixed the bug (and seems to compile the project in about half the time it took in MSVC 8.0 :-)))). We found a fix that should be applied to boost/pool/detail/mutex.hpp: The CRITICAL_SECTION type should be referenced using its fully qualified name '::CRITICAL_SECTION'. I am attaching a suggested patch file for boost/pool/detail/mutex.hpp. If no problems are found with it should be applied to the trunkas well as the release branch for the upcoming 1.35.1 patch release. The patch uses fully qualified names for other global Windows/posix API calls as well (e.g ::InitializeCriticalSection(), ::DeleteCriticalSection(), ::EnterCriticalSection(), ::LeaveCriticalSection()) but that does not have direct impact on this concrete bug. The following source file demonstrates the bug using boost libraries: #include "boost/archive/text_iarchive.hpp" #include "boost/pool/pool_alloc.hpp" int main() {} It should fail to build with an error message similar to: X:\Resources\Libraries\Boost\boost_1_35_0\boost\pool\detail\mutex.hpp(67) : error C2872: 'CRITICAL_SECTION' : ambiguous symbol could be 'X:\Resources\Libraries\PlatformSDK\Version_6.0\Include\WinBase.h(314) : RTL_CRITICAL_SECTION CRITICAL_SECTION' or 'X:\Resources\Libraries\Boost\boost_1_35_0\boost\detail\lwm_win32_cs.hpp(33) : boost::detail::CRITICAL_SECTION' Perhaps someone knows how and where to add the above example as a part of some regression test suite on MSVC 7.1 & 8.0? Here is also a minimal example demonstrating the same compiler bug without using any external libraries: namespace One { class Brick; } namespace Two { using namespace One; template <class TinyTemplateParam> class TinyClass {}; } class Brick {}; Brick brick; int main() {} Hope this helps. Best regards, Jurko Gospodnetić Index: pool/detail/mutex.hpp =================================================================== --- pool/detail/mutex.hpp (revision 44110) +++ pool/detail/mutex.hpp (working copy) @@ -64,23 +64,23 @@ class win32_mutex { private: - CRITICAL_SECTION mtx; + ::CRITICAL_SECTION mtx; win32_mutex(const win32_mutex &); void operator=(const win32_mutex &); public: win32_mutex() - { InitializeCriticalSection(&mtx); } + { ::InitializeCriticalSection(&mtx); } ~win32_mutex() - { DeleteCriticalSection(&mtx); } + { ::DeleteCriticalSection(&mtx); } void lock() - { EnterCriticalSection(&mtx); } + { ::EnterCriticalSection(&mtx); } void unlock() - { LeaveCriticalSection(&mtx); } + { ::LeaveCriticalSection(&mtx); } }; #endif // defined(BOOST_WINDOWS) @@ -90,23 +90,23 @@ class pthread_mutex { private: - pthread_mutex_t mtx; + ::pthread_mutex_t mtx; pthread_mutex(const pthread_mutex &); void operator=(const pthread_mutex &); public: pthread_mutex() - { pthread_mutex_init(&mtx, 0); } + { ::pthread_mutex_init(&mtx, 0); } ~pthread_mutex() - { pthread_mutex_destroy(&mtx); } + { ::pthread_mutex_destroy(&mtx); } void lock() - { pthread_mutex_lock(&mtx); } + { ::pthread_mutex_lock(&mtx); } void unlock() - { pthread_mutex_unlock(&mtx); } + { ::pthread_mutex_unlock(&mtx); } }; #endif // defined(_POSIX_THREADS) || defined(BOOST_HAS_PTHREADS)

Hi all.
One of our projects failed to build using the Boost 1.35 release and we traced it down to a compiler bug with MSVC 7.1. & 8.0. We have not tested any earlier compiler versions and MSVB 9.0 seems to have fixed the bug (and seems to compile the project in about half the time it took in MSVC 8.0 :-)))).
We found a fix that should be applied to boost/pool/detail/mutex.hpp:
The CRITICAL_SECTION type should be referenced using its fully qualified name '::CRITICAL_SECTION'.
I am attaching a suggested patch file for boost/pool/detail/mutex.hpp. If no problems are found with it should be applied to the trunk as well as the release branch for the upcoming 1.35.1 patch release.
The patch uses fully qualified names for other global Windows/posix API calls as well (e.g ::InitializeCriticalSection(), ::DeleteCriticalSection(), ::EnterCriticalSection(), ::LeaveCriticalSection()) but that does not have direct impact on this concrete bug.
Just pinging to make sure this patch does not get lost. It is quite simple, I see no way it could mess things up and it definitively solves compilation problems when compiling with MSVC 7.1 or 8.0, so should I commit it directly to the trunk?
Perhaps someone knows how and where to add the above example as a part of some regression test suite on MSVC 7.1 & 8.0?
Can anyone provide hints on where and how to add a test for this? The code should be simple - just the one given in the previous mail: #include "boost/archive/text_iarchive.hpp" #include "boost/pool/pool_alloc.hpp" int main() {} Best regards, Jurko Gospodnetić

Jurko Gospodnetić:
Can anyone provide hints on where and how to add a test for this? The code should be simple - just the one given in the previous mail:
#include "boost/archive/text_iarchive.hpp" #include "boost/pool/pool_alloc.hpp" int main() {}
I'd #include the conflicting "boost/detail/lightweight_mutex.hpp" directly. To add a test case, the usual procedure is to add a foo_my_test.cpp file in the libs/foo/test directory and a corresponding "run foo_my_test" line in the Jamfile. Unfortunately some libraries - pool among them - do not have their tests factored out in this way and are instead inlined into status/Jamfile.v2. It currently contains run libs/pool/test/test_pool_alloc.cpp test_exec_monitor ; without even being wrapped in a test-suite. You'll probably need to add a second similar line (test_exec_monitor is not necessary for this simple test.)

Peter Dimov wrote:
Unfortunately some libraries - pool among them - do not have their tests factored out in this way and are instead inlined into status/Jamfile.v2.
Perhaps we should fix that? -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera:
Peter Dimov wrote:
Unfortunately some libraries - pool among them - do not have their tests factored out in this way and are instead inlined into status/Jamfile.v2.
Perhaps we should fix that?
We just need a volunteer who is not afraid of Jamfiles. :-)

Peter Dimov wrote:
Rene Rivera:
Peter Dimov wrote:
Unfortunately some libraries - pool among them - do not have their tests factored out in this way and are instead inlined into status/Jamfile.v2. Perhaps we should fix that?
We just need a volunteer who is not afraid of Jamfiles. :-)
Done for the array tests. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

New subject for the benefit of those not reading every post... Rene Rivera wrote:
Peter Dimov wrote:
Rene Rivera:
Peter Dimov wrote:
Unfortunately some libraries - pool among them - do not have their tests factored out in this way and are instead inlined into status/Jamfile.v2. Perhaps we should fix that? We just need a volunteer who is not afraid of Jamfiles. :-)
Done for the array tests.
Done for the CRC tests. I figure I might as well fix as many as I can now, at the start of the release cycle. So that we catch any problems on this early. But the config tests are rather difficult to deal with. John any chance of fixing the config tests for this release? -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera wrote:
New subject for the benefit of those not reading every post...
Rene Rivera wrote:
Peter Dimov wrote:
Rene Rivera:
Peter Dimov wrote:
Unfortunately some libraries - pool among them - do not have their tests factored out in this way and are instead inlined into status/Jamfile.v2. Perhaps we should fix that? We just need a volunteer who is not afraid of Jamfiles. :-) Done for the array tests.
Done for the CRC tests.
And done for the pool tests. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera wrote:
Rene Rivera wrote:
New subject for the benefit of those not reading every post...
Rene Rivera wrote:
Peter Dimov wrote:
Rene Rivera:
Peter Dimov wrote:
Unfortunately some libraries - pool among them - do not have their tests factored out in this way and are instead inlined into status/Jamfile.v2. Perhaps we should fix that? We just need a volunteer who is not afraid of Jamfiles. :-) Done for the array tests. Done for the CRC tests.
And done for the pool tests.
Functional done also. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
New subject for the benefit of those not reading every post...
Rene Rivera wrote:
Peter Dimov wrote:
Rene Rivera:
Peter Dimov wrote: > Unfortunately some libraries - pool among them - do not have > their tests factored out in this way and are instead inlined into > status/Jamfile.v2. Perhaps we should fix that? We just need a volunteer who is not afraid of Jamfiles. :-) Done for the array tests. Done for the CRC tests. And done for the pool tests.
Functional done also.
Same for integer tests. PS. I take donations <http://sourceforge.net/donate/index.php?user_id=33595> ;-) -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
New subject for the benefit of those not reading every post...
Rene Rivera wrote:
Peter Dimov wrote:
Rene Rivera: > Peter Dimov wrote: >> Unfortunately some libraries - pool among them - do not have >> their tests factored out in this way and are instead inlined into >> status/Jamfile.v2. > Perhaps we should fix that? We just need a volunteer who is not afraid of Jamfiles. :-) Done for the array tests. Done for the CRC tests. And done for the pool tests. Functional done also.
Same for integer tests.
Dito for preprocessor library. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
New subject for the benefit of those not reading every post...
Rene Rivera wrote:
Peter Dimov wrote: > Rene Rivera: >> Peter Dimov wrote: >>> Unfortunately some libraries - pool among them - do not have >>> their tests factored out in this way and are instead inlined into >>> status/Jamfile.v2. >> Perhaps we should fix that? > We just need a volunteer who is not afraid of Jamfiles. :-) Done for the array tests. Done for the CRC tests. And done for the pool tests. Functional done also. Same for integer tests.
Dito for preprocessor library.
Similarly for rational tests. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote: > Peter Dimov wrote: >> Rene Rivera: >>> Peter Dimov wrote: >>>> Unfortunately some libraries - pool among them - do not have >>>> their tests factored out in this way and are instead inlined into >>>> status/Jamfile.v2. >>> Perhaps we should fix that? >> We just need a volunteer who is not afraid of Jamfiles. :-) > Done for the array tests. Done for the CRC tests. And done for the pool tests. Functional done also. Same for integer tests. Dito for preprocessor library. Similarly for rational tests.
Look at all that pretty quoting :-) Timer tests equally modified. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote: > Rene Rivera wrote: >> Peter Dimov wrote: >>> Rene Rivera: >>>> Peter Dimov wrote: >>>>> Unfortunately some libraries - pool among them - do not have >>>>> their tests factored out in this way and are instead inlined into >>>>> status/Jamfile.v2. >>>> Perhaps we should fix that? >>> We just need a volunteer who is not afraid of Jamfiles. :-) >> Done for the array tests. > Done for the CRC tests. And done for the pool tests. Functional done also. Same for integer tests. Dito for preprocessor library. Similarly for rational tests. Look at all that pretty quoting :-) Timer tests equally modified.
Last, but not least, the tokenizer tests. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote: > Rene Rivera wrote: >> Rene Rivera wrote: >>> Peter Dimov wrote: >>>> Rene Rivera: >>>>> Peter Dimov wrote: >>>>>> Unfortunately some libraries - pool among them - do not have >>>>>> their tests factored out in this way and are instead inlined into >>>>>> status/Jamfile.v2. >>>>> Perhaps we should fix that? >>>> We just need a volunteer who is not afraid of Jamfiles. :-) >>> Done for the array tests. >> Done for the CRC tests. > And done for the pool tests. Functional done also. Same for integer tests. Dito for preprocessor library. Similarly for rational tests. Look at all that pretty quoting :-) Timer tests equally modified.
Last, but not least, the tokenizer tests.
*clap* *clap* *clap* *bow* *bow* *bow* :-) Best regards, Jurko Gospodnetić

Jurko Gospodnetic' wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote: > Rene Rivera wrote: >> Rene Rivera wrote: >>> Rene Rivera wrote: >>>> Peter Dimov wrote: >>>>> Rene Rivera: >>>>>> Peter Dimov wrote: >>>>>>> Unfortunately some libraries - pool among them - do not have >>>>>>> their tests factored out in this way and are instead inlined into >>>>>>> status/Jamfile.v2. >>>>>> Perhaps we should fix that? >>>>> We just need a volunteer who is not afraid of Jamfiles. :-) >>>> Done for the array tests. >>> Done for the CRC tests. >> And done for the pool tests. > Functional done also. Same for integer tests. Dito for preprocessor library. Similarly for rational tests. Look at all that pretty quoting :-) Timer tests equally modified. Last, but not least, the tokenizer tests.
*clap* *clap* *clap*
*bow* *bow* *bow*
:-D WARNING: Testers will need to do a full run so that stale results are cleaned up. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote:
Rene Rivera wrote: > Rene Rivera wrote: >> Rene Rivera wrote: >>> Peter Dimov wrote: >>>> Rene Rivera: >>>>> Peter Dimov wrote: >>>>>> Unfortunately some libraries - pool among them - do not have >>>>>> their tests factored out in this way and are instead inlined >>>>>> into >>>>>> status/Jamfile.v2. >>>>> Perhaps we should fix that? >>>> We just need a volunteer who is not afraid of Jamfiles. :-) >>> Done for the array tests. >> Done for the CRC tests. > And done for the pool tests. Functional done also. Same for integer tests. Dito for preprocessor library. Similarly for rational tests. Look at all that pretty quoting :-) Timer tests equally modified. Last, but not least, the tokenizer tests.
Thank you for both the work and the pretty pictures. :-)

Rene, Is there a reason why you removed the (new) Spirit V2 tests? Regards Hartmut
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost- bounces@lists.boost.org] On Behalf Of Rene Rivera Sent: Sunday, April 13, 2008 5:31 PM To: boost@lists.boost.org Subject: [boost] Normalizing wayward status/Jamfile.v2 tests.
New subject for the benefit of those not reading every post...
Rene Rivera wrote:
Peter Dimov wrote:
Rene Rivera:
Peter Dimov wrote:
Unfortunately some libraries - pool among them - do not have their tests factored out in this way and are instead inlined into status/Jamfile.v2. Perhaps we should fix that? We just need a volunteer who is not afraid of Jamfiles. :-)
Done for the array tests.
Done for the CRC tests.
I figure I might as well fix as many as I can now, at the start of the release cycle. So that we catch any problems on this early. But the config tests are rather difficult to deal with. John any chance of fixing the config tests for this release?
-- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Hartmut Kaiser wrote:
Is there a reason why you removed the (new) Spirit V2 tests?
Hm, I thought I merged that in. So... Yes, the reason is I made a mistake ;-) Fixed now though. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera wrote:
Hartmut Kaiser wrote:
Is there a reason why you removed the (new) Spirit V2 tests?
Hm, I thought I merged that in. So... Yes, the reason is I made a mistake ;-) Fixed now though.
Thanks! Regards Hartmut

Rene Rivera wrote:
Done for the CRC tests.
I figure I might as well fix as many as I can now, at the start of the release cycle. So that we catch any problems on this early. But the config tests are rather difficult to deal with. John any chance of fixing the config tests for this release?
OK, I'll look into it ASAP. John.

Hi all.
One of our projects failed to build using the Boost 1.35 release and we traced it down to a compiler bug with MSVC 7.1. & 8.0. We have not tested any earlier compiler versions and MSVB 9.0 seems to have fixed the bug (and seems to compile the project in about half the time it took in MSVC 8.0 :-)))).
We found a fix that should be applied to boost/pool/detail/mutex.hpp:
The CRITICAL_SECTION type should be referenced using its fully qualified name '::CRITICAL_SECTION'.
I am attaching a suggested patch file for boost/pool/detail/mutex.hpp. If no problems are found with it should be applied to the trunk as well as the release branch for the upcoming 1.35.1 patch release.
The patch uses fully qualified names for other global Windows/posix API calls as well (e.g ::InitializeCriticalSection(), ::DeleteCriticalSection(), ::EnterCriticalSection(), ::LeaveCriticalSection()) but that does not have direct impact on this concrete bug.
Since there were no complaints and the patch is really simple, I have gone ahead and comitted it, together with a corresponding regression test. Changeset link: http://svn.boost.org/trac/boost/changeset/44480 Best regards, Jurko Gospodnetić
participants (5)
-
Hartmut Kaiser
-
John Maddock
-
Jurko Gospodnetić
-
Peter Dimov
-
Rene Rivera