Boost Users :
Subject: Re: [Boost-users] boost exception question when threading library header is included.
From: Kim Barrett (kab.conundrums_at_[hidden])
Date: 2011-06-10 11:19:02
On Jun 10, 2011, at 2:25 AM, Robert Ramey wrote:
> I am building a small ap to test the ASIO library. I run my test ap and
> things run as expected.
> But when I set my IDE options (MSVC 8.0) to trap when an exception is
> thrown, I get
> an exception thrown before main(.. is invoked. The call stack looks like:
> [... call stack details snipped ...]
> this seems to point an attempt to copy something non_copyable in the
> boost.exception library.
> Can anyone help me understand what's going on here and what I should do
> about it?
This also confused me for a while when I first ran into it (on linux, under gdb, using "catch throw").
What I'm seeing is that boost.exception forces a call to its get_bad_alloc() function at static initialization time in an attempt to ensure (early?) once-only initialization of the function scoped static variable within get_bad_alloc. That first call to get_bad_alloc() (at static initialization time) calls copy_exception, which is implemented as a try/catch around a throw of the argument exception, with the catch clause returning the result of current_exception. It is that throw within copy_exception that is tripping the trap on exceptions. Once you recognize that's where you are at, you can safely continue from the trap, let the copy_exception complete, and the application startup proceed.
It looks like things are being done differently in this area on trunk and current release branches, but I'm not sure how far back that change goes. (I'm presently using boost 1.43, which is where I looked to figure out what was happening.) So it might be that this annoying behavior has been eliminated in a more recent version of boost (or possibly the next version).
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