Boost logo

Boost Users :

Subject: [Boost-users] Boost 1.43 - Exception before main() is called
From: Rob Yull (ryull_at_[hidden])
Date: 2010-05-12 10:13:09


I recently upgrade from boost 1.42 to 1.43. All of a sudden, the project I
was working on seems to be throwing an exception before main() is called. I
was able to reproduce this error in the example below. Using 1.42, it
executes just fine. Using 1.43, an exception is thrown before main is
reached.

 

In some of my classes, I have a static mutex variable that I lock before I
manipulate other static variables in the class (as seen below).

 

main.cpp - Start

#include "Test.hpp"

 

int main()

{

                Test test;

 

                return 0;

}

main.cpp - End

 

Test.hpp - Start

#ifndef DEFINE_TEST_HPP

#define DEFINE_TEST_HPP

 

#include <boost/thread.hpp>

 

class Test

{

public:

                Test();

                ~Test();

 

private:

                typedef boost::mutex StaticMutex;

                static StaticMutex s_Mutex;

                typedef boost::lock_guard<StaticMutex>
StaticMutexLock;

};

 

#endif // DEFINE_TEST_HPP

Test.hpp - End

 

Test.cpp - Start

#include "Test.hpp"

 

Test::StaticMutex Test::s_Mutex;

 

Test::Test()

{

                const StaticMutexLock Lock(s_Mutex);

}

 

Test::~Test()

{

}

Test.cpp - End

 

The code above, when using boost 1.43, produces the following error in both
VC2010 Express and VC2005 Pro.

First-chance exception at 0x7569b727 (KernelBase.dll) in BoostTest.exe:
Microsoft C++ exception:
boost::exception_detail::clone_impl<boost::exception_detail::bad_alloc_> at
memory location 0x0030f6e4..

 

The call stack (>>> is where the exception is caught).

KernelBase.dll!_RaiseException_at_16() + 0x58 bytes

msvcr100d.dll!_CxxThrowException(void * pExceptionObject, const
_s__ThrowInfo * pThrowInfo) Line 157 C++

>>>BoostTest.exe!boost::copy_exception<boost::exception_detail::bad_alloc_>(
const boost::exception_detail::bad_alloc_ & e) Line 47 C++

BoostTest.exe!boost::exception_detail::get_bad_alloc<42>() Line 80 + 0x9f
bytes C++

BoostTest.exe!`dynamic initializer for
'boost::exception_detail::exception_ptr_bad_alloc<42>::e''() Line 94 + 0x28
bytes C++

msvcr100d.dll!_initterm(void (void)* * pfbegin, void (void)* * pfend) Line
873 C

BoostTest.exe!__tmainCRTStartup() Line 473 + 0xf bytes C

BoostTest.exe!mainCRTStartup() Line 371 C

kernel32.dll!@BaseThreadInitThunk_at_12() + 0x12 bytes

ntdll.dll!___RtlUserThreadStart_at_8() + 0x27 bytes

ntdll.dll!__RtlUserThreadStart_at_8() + 0x1b bytes

 

Did something change between 1.42 and 1.43 that would cause this?

 

-Rob Yull

 



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net