In an small project i am using several boost packages (asio, property_tree, filesystem, etc.) and i had to notice, that everything works fine, until an exception gets thrown somewhere in the boost packages. It happens in all those packages, but i was now able to boil it down to the following minimal program:
#include <iostream>
#include "boost/throw_exception.hpp"
int main(int argc, char* argv[])
{
boost::throw_exception(std::exception("foo")); // <-- this will produce the problem
throw std::exception("foo"); // <-- this works as expected
return 0;
}
The exception is thrown fine, but when the program terminates i get
Run-Time Check Failure #0 - The value of ESP was not properly
saved across a function call ...
I tried to debug this (i am using boost 1.49.0 in visual studio 2010 express with crt statically linked) but the problem appears when all visible code is already executed. I can see that the std:exception destructor wen't through, but after that ("in" the return statement of my program) the message box is triggered.
EDIT: Some additional infos:
- In the minimal program above, boost is only used headers only
- No other lib-files are involved
- Only ntdll.dll and kernel32.dll are loaded by the program
- No additional threads are beeing created
- The problem also appears, when i link dynamically against CRT
EDIT2: Again more infos:
- added includes in the program above
- the problem appears too, when i throw a runtime_error instead
- the problem vanishes when i catch the exception with (...) or (std::exception)
- the problem even remains cured, when i rethrow the exception