Hi,
I don't know how to start the story of the mingw-w64 problem with SEH and Typed exception because it is a very complex problem. The last mingw gcc that I know works is gcc.exe (GCC) 8.2.0 while the newer mingw-w64 DOES NOT WORK.

I would ask someone who understands the problem to try to help me in any way and I will be very grateful to him.

And here is a brief description of the scenario that is necessary for me to make my ERP ISPP-64 work as follows:
1. ERP is in the main process
2. In the DLL process, ODBC is communication with the PostgreSQL DB server and as such it generates an SQLException 3. In the DLL process, XCURSES is an ERP GUI that does not generate any exceptions

The problem with mingw-w64 is that ABI does not support in the main process an exception that is generated in some DLL process. I solved this problem for gcc.exe (GCC) 8.2.0 but for newer GCC I don't know how to do it.

Below is Dr. Mingw report (backtrace) test program with (GCC) 10.2.0 as an attempt to determine the problem: 1. [/home/scarlet/Projects/mingw-w64-builds/pkg/mingw-w64-crt/src/mingw-w64-v7.0.0/mingw-w64-crt/crt/crtexe.c @ 339]
2. [/asoft-src/ispp-64/win32/cc/pomocni/test-mingw-exception.cpp @ 1015]
3. [/asoft-src/ispp-64/win32/cc/pomocni/test-mingw-exception.cpp @ 987]
An attempt is made here to connect to a datasource that does not exist and ODBC will generate an SQLException 4. [/asoft-src/ispp-64/linux/cross-compile/libodbc++-0.2.3/libodbc/../../../..//libodbc++-0.2.3/src/drivermanager.cpp @ 221] 5. [/asoft-src/ispp-64/linux/cross-compile/libodbc++-0.2.3/libodbc/../../../..//libodbc++-0.2.3/src/connection.cpp @ 220] 6. [/asoft-src/ispp-64/linux/cross-compile/libodbc++-0.2.3/libodbc/../../../..//libodbc++-0.2.3/src/connection.cpp @ 506] 7. [/asoft-src/ispp-64/linux/cross-compile/libodbc++-0.2.3/libodbc/../../../..//libodbc++-0.2.3/src/errorhandler.cpp @ 294] 8. [/asoft-src/ispp-64/linux/cross-compile/libodbc++-0.2.3/libodbc/../../../../libodbc++-0.2.3/include/odbc++/types. h @ 722] 9. [/asoft-src/ispp-64/linux/cross-compile/libodbc++-0.2.3/libodbc/../../../../libodbc++-0.2.3/include/odbc++/sqlexception. h @ 14]    Here the ODBC DLL calls a function (throwisppMainSQLException) that is in the main process to satisfy the ABI.
   The following lines 833 to 892 of the test program show the following:
   Although __try1 is active (line 864) SEH is not captured but Dr. Mingw reports on "Integer division by zero" on line 867!

backtrace.log + missing code

----------------------------------
   833:#if __MINGW64__ && ((__GNUC__ == 9 && __GNUC_MINOR__ >= 3) || __GNUC__ >= 10)
   834:class SEH_EXCEPTION_RECORD_CLASS : public std::exception {
   835:  _EXCEPTION_RECORD *e;
   836:  public:
   837:  SEH_EXCEPTION_RECORD_CLASS(_EXCEPTION_RECORD *exception_record, void *err, _CONTEXT *context, void *par) {
   838:    e = exception_record;
   839:  }
   840:  ~SEH_EXCEPTION_RECORD_CLASS() throw () {
   841:  }
   842:  const char* what() const throw() override {
   843:    return "SEH";
   844:  }
   845:  int getExceptionCode() const {
   846:    return e->ExceptionCode;
   847:  }
   848:};
   849:
   850:extern "C" EXCEPTION_DISPOSITION _catchVK(_EXCEPTION_RECORD *exception_record, void *err, _CONTEXT *context, void *par) noexcept(false) {    851:  SEH_EXCEPTION_RECORD_CLASS SEH_VK(exception_record, err, context, par);
   852:  throw SEH_VK;
   853:}
   854:#endif
   855:
   856:static const void throwisppMainSQLException(odbc::SQLException *e) noexcept(false) {    857:#if __MINGW64__ && ((__GNUC__ == 9 && __GNUC_MINOR__ >= 3) || __GNUC__ >= 10)
   858:  vkSQLException vke(e);
   859:
   860:  std::cerr << std::endl << "In throwisppMainSQLException SQLException: Reason=" << e->what() <<    861:      " sqlState=" << e->getSQLState() << " errorCode=" << e->getErrorCode() << std::endl;
   862:
   863:  try {
   864:    __try1(_catchVK)

pomocni.exe caused an Integer division by zero at location 0000000000401A93 in module pomocni.exe.

AddrPC           Params
0000000000401A93 0000000000000000 0000000000000000 0000000000000000  pomocni.exe!throwisppMainSQLException [/asoft-src/ispp-64/win32/cc/pomocni/test-mingw-exception.cpp @ 867]
   865:     signal(SIGFPE, SIG_DFL);
   866:     int x, y = 0;
>  867:     x = 5 / y;
   868:     __except1
   869:     return;
   870:  } catch (SEH_EXCEPTION_RECORD_CLASS & seh) {
   871:    char buf [100];
   872:    wsprintf(buf, "Structured Exception Error 0x%x", seh.getExceptionCode());    873:    MessageBox(0, buf, "Structured Exception", MB_ICONEXCLAMATION | MB_OK);
   874:  }
   875:
   876:  try {
   877:    __try1(_catchVK)
   878:        int (*foo)() = NULL;
   879:    foo();
   880:    __except1
   881:  } catch (_EXCEPTION_RECORD* seh) {
   882:    char buf [100];
   883:    wsprintf(buf, "Structured Exception Error 0x%x", seh->ExceptionCode);    884:    MessageBox(0, buf, "Structured Exception", MB_ICONEXCLAMATION | MB_OK);
   885:  }
   886:
   887:  throw vke;
   888:  std::cerr << std::endl << "In throwisppMainSQLException This line is never executed !" << std::endl;
   889:#else
   890:  throw *e;
   891:#endif
   892:}

000000006A781403 0000000000000000 0000000000000000 0000000000000000  liblibodbc.dll!throwisppMainSQLException [/asoft-src/ispp-64/linux/cross-compile/libodbc++-0.2.3/libodbc/../../../../libodbc++-0.2.3/include/odbc++/sqlexception.h @ 14]
    12:   if (isppMainSQLException) {
    13:     void (*isppMainSQLException1) (struct SQLException *) = (void (*)(struct SQLException *))isppMainSQLException;
>   14:     isppMainSQLException1((struct SQLException *)e);
    15:   }
    16: }

000000006A7AC6C5 0000000000000000 0000000000000000 0000000000000000  liblibodbc.dll!throwException [/asoft-src/ispp-64/linux/cross-compile/libodbc++-0.2.3/libodbc/../../../../libodbc++-0.2.3/include/odbc++/types.h @ 722]
   720:
   721:     /** Destructor */
>  722:     virtual ~SQLExceptionOdbc() throw() {}
   723:
   724:     /** Get the vendor error code of this exception */

000000006A792074 0000000000000000 0000000000000000 0000000000000000  liblibodbc.dll!_checkErrorODBC3 [/asoft-src/ispp-64/linux/cross-compile/libodbc++-0.2.3/libodbc/../../../..//libodbc++-0.2.3/src/errorhandler.cpp @ 294]
   292: #ifdef __MINGW32__
   293:       SQLException e(errmsg, m->getSQLState(), m->getNativeCode());
>  294:       e.throwException();
   295: #else
   296:       throw SQLException(errmsg, m->getSQLState(), m->getNativeCode());

000000006A7A909B 0000000000000000 0000000000000000 0000000000000000  liblibodbc.dll!_checkConError [/asoft-src/ispp-64/linux/cross-compile/libodbc++-0.2.3/libodbc/../../../..//libodbc++-0.2.3/src/connection.cpp @ 506]
   504:   this->_registerStatement(cstmt);
   505:   return cstmt;
>  506: }
   507:

000000006A783543 0000000000000000 0000000000000000 0000000000000000  liblibodbc.dll!_connect [/asoft-src/ispp-64/linux/cross-compile/libodbc++-0.2.3/libodbc/../../../..//libodbc++-0.2.3/src/connection.cpp @ 220]
   218:        x);
   219:
>  220:   this->_checkConError(hdbc_,r,"Failed to connect to datasource");
   221:
   222:   driverInfo_=new DriverInfo(this);

000000006A790F9A 0000000000000000 0000000000000000 0000000000000000  liblibodbc.dll!getConnection [/asoft-src/ispp-64/linux/cross-compile/libodbc++-0.2.3/libodbc/../../../..//libodbc++-0.2.3/src/drivermanager.cpp @ 221]
   219:
   220:   Connection* con=DriverManager::_createConnection();
>  221:   con->_connect(connectString);
   222:   return con;
   223: }

0000000000401DDB 0000000000000000 0000000000000000 0000000000000000  pomocni.exe!mainVK [/asoft-src/ispp-64/win32/cc/pomocni/test-mingw-exception.cpp @ 987]    985:     std::cout << "Connecting to TRT-MRT-CVRC-KVRC ..." << std::endl << std::flush;
   986:     odbc::DriverManager::setConnectionPooling( true );
>  987:     con = odbc::DriverManager::getConnection("TRT-MRT-CVRC-KVRC");
   988:     if (con)
   989:       ;

0000000000402262 0000000000000000 0000000000000000 0000000000000000  pomocni.exe!main [/asoft-src/ispp-64/win32/cc/pomocni/test-mingw-exception.cpp @ 1015]
  1010:int main( int argc, char *argv[] ) {
  1011:#if __MINGW64__ && ((__GNUC__ == 9 && __GNUC_MINOR__ >= 3) || __GNUC__ >= 10)
  1012://  std::set_terminate(custom_terminate);
  1013:   icky_global_program_name = argv[0];
  1014: //  set_signal_handler();
> 1015:   mainVK();
  1016: #else
  1017:   odbc::isppMainSQLException = (void *)&throwisppMainSQLException;

00000000004013B4 0000000000000000 0000000000000000 0000000000000000  pomocni.exe!__tmainCRTStartup [/home/scarlet/Projects/mingw-w64-builds/pkg/mingw-w64-crt/src/mingw-w64-v7.0.0/mingw-w64-crt/crt/crtexe.c @ 339]



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to