[odb-users] ODB exception problem

cetoni GmbH - Uwe Kindler uwe.kindler at cetoni.de
Thu Jun 9 07:26:54 EDT 2011


while evaluating ODB we stumbled on a serious problem catching 
exceptions from libodb.

The following example shows the problem

int main()
     boost::shared_ptr<database> db;
     cout << "Hello World!!!" << endl;
     db = boost::shared_ptr<database>(new odb::sqlite::database(
     transaction t(db->begin());
         odb::schema_catalog::create_schema (*db);
     catch (odb::unknown_schema& ex)
         std::cout << ex.what() << std::endl;
     catch (...)
         std::cout << "Exception" << std::endl;
     return 0;

This application produces the following output:

This application has requested the Runtime to terminate it in an unusual 
Please contact the application's support team for more information.
Hello World!!!
terminate called after throwing an instance of 'odb::unknown_schema'
   what():  unknown database schema ''

The "Hello World!!!" message appears on stdout and the rest appares on 
stderr if I start the application in eclipse.

If I insert the following line

throw odb::unknown_schema("Test");

before odb::schema_catalog::create_schema (*db); then I get the 
following output:

Hello World!!!
unknown database schema 'Test'

So it seems like it is not possible to catch exceptions thrown from 
libodb because normally the application should run into the first catch 
block because odb::schema_catalog::create_schema (*db) throws an 
unknown_schema exception like it happens if I insert the throw 
odb::unknown_schema("Test") command . This is quite strange because we 
use DLLs extensively and never discovered such a problem. We discovered 
the problem in our Qt application and I created this tiny exampleto 
check if it is a problem of our Qt application or if this problem 
occures always.

Our environment:

Windows 7
MinGW with GCC4.5.1
libodb configuration: ./configure --disable-static 

We have no idea what could cause this problem but ist must be something 
in libodb compilation or linkage because we never had any problems to 
throw exceptions across DLL boundaries.

Any idea what goes wrong here?

Thank you for any help.

More information about the odb-users mailing list