I running a development host:
root@lx1217:/usr/src/testw1# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.3 (jessie)
Release: 8.3
Codename: jessie
-
root@lx1217:/usr/src/testw1# uname -a
Linux lx1217 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u4 (2016-02-29) x86_64 GNU/Linux
I did a very small program:
#include <iostream>
#include "../ibpp/core/ibpp.h"
int main()
{
std::cout << "Hello world" << std::endl;
try
{
IBPP::Database db = IBPP::DatabaseFactory("myserver", "/data/db.fdb", "username", "password");
db->Connect();
db->Disconnect();
}
catch (IBPP::Exception& e)
{
std::cout << e.ErrorMessage();
}
return(0);
}
The ibpp packages come from http://www.ibpp.org/. After installing all prerequsites
libfbclient2:amd64 pkg-config:amd64 mingw-w64:amd64 gcc-4.9-locales:amd64
and after hacking the ibpp package ./ibpp/core/all_in_one.cpp and adding
#ifdef IBPP_WINDOWS
#include <windows.h>
#endif
#include <sstream>
#include <time.h>
at the top of file to face the "#undef _WIN32" solution of ./ibpp/core/_ibpp.h, my test.cpp compiles very well for three architectures:
i686-w64-mingw32-gcc-4.9-win32 --static -m32 -mthreads -mabi=ms -DIBPP_WINDOWS ../ibpp/core/all_in_one.cpp test.cpp -o test32.exe -lstdc++
x86_64-w64-mingw32-gcc-4.9-win32 --static -m64 -mthreads -mabi=ms -DIBPP_WINDOWS ../ibpp/core/all_in_one.cpp test.cpp -o test64.exe -lstdc++
x86_64-linux-gnu-gcc -m64 -mabi=sysv -DIBPP_LINUX ../ibpp/core/all_in_one.cpp test.cpp -o test64 -lstdc++ -lfbclient -lm
Regarding to the dummy paramters for creating the databse instance db the call to db->Connect() throws an exception. That's where my problems starts:
This exception get cought as excepted in i686-w64-mingw32-gcc-4.9-win32 and in x86_64-linux-gnu-gcc but abnormaly terminates the program in x86_64-w64-mingw32-gcc-4.9-win32.
The windows programs run under Windows v8.1 x64.
Now I red a lot of about exception handling concepts, the differences between sjlj, dwarf and seh.
I learned somethin about ABI's and how to determine which EH modell ist used for the architectures:
-rw-r--r-- 1 root root 2826650 Dez 20 2014 /usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/libgcc.a
-rw-r--r-- 1 root root 10070 Dez 20 2014 /usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/libgcc_eh.a
-rw-r--r-- 1 root root 67518 Dez 20 2014 /usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/libgcc_s.a
-rw-r--r-- 1 root root 565002 Dez 20 2014 /usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/libgcc_s_seh-1.dll
-rw-r--r-- 1 root root 3068828 Dez 20 2014 /usr/lib/gcc/i686-w64-mingw32/4.9-win32/libgcc.a
-rw-r--r-- 1 root root 18452 Dez 20 2014 /usr/lib/gcc/i686-w64-mingw32/4.9-win32/libgcc_eh.a
-rw-r--r-- 1 root root 69422 Dez 20 2014 /usr/lib/gcc/i686-w64-mingw32/4.9-win32/libgcc_s.a
-rw-r--r-- 1 root root 528566 Dez 20 2014 /usr/lib/gcc/i686-w64-mingw32/4.9-win32/libgcc_s_sjlj-1.dll
-rw-r--r-- 1 root root 3063526 Dez 25 2014 /usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc.a
-rw-r--r-- 1 root root 53820 Dez 25 2014 /usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a
lrwxrwxrwx 1 root root 35 Dez 25 2014 /usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_s.so -> /lib/x86_64-linux-gnu/libgcc_s.so.1
So gcc uses
sjlj for i686-w64-mingw32-gcc-4.9-win32
seh for x86_64-w64-mingw32-gcc-4.9-win32
eh for x86_64-linux-gnu-gcc (?)
I stepped a little bit around and found, if you throw an exception (just using throw 1) in ../ibpp/core/database.cpp just before in line #90 an object get created (DPB dpb;) than all works fine. But if you throw an exception in line #91 just after the object was created, the program terminates abnormal at x86_64-w64-mingw32.
I red some articles about exceptions in destructors and that they must lead to an abnormal program termination. That makes sense. But I reviewed the code from the class an there is nothing special in the called destructores what may lead to an uncaught exception in them.
Because of compiling with the package-tools I guess that there can be no ABI problems nor any EH-model changes between the modules/libs.
So, ending up in my little question: Why my program terminates abnormaly on x86_64-w64-mingw32?