Hi,

After some experimentation, it appears that my problem is much more
generic than what I had initially thought, and has no relation to
MATLAB. It seems to systematically happen when a C++ exception is thrown
by a DLL compiled using Visual C++ (x64) and linked to an executable
compiled using MinGW-w64 (x64-targeted).

I attach a small testcase that you should be able to reproduce, provided
that you have Visual C++ for x64 (I have the 2008 edition).

First, compile the DLL with Visual C++:

cl /c mylib.cc
link /dll /machine:x64 /export:exception_thrower /out:libmylib.dll mylib.obj

Then compile the executable with MinGW:

x86_64-w64-mingw32-g++ -g -O2 -Wall -I. crashtest.cc -o crashtest.exe -L. 
-lmylib

Finally copy libgcc_s_sjlj-1.dll and libstdc++-6.dll in the current directory.

The resulting executable crashes with a stack overflow, instead of
displaying the expected message.

Note that if you compile the DLL with MinGW-w64, everything works fine.

Sorry if this is a known issue.

Best regards,

-- 
Sébastien Villemot
CEPREMAP — http://www.cepremap.ens.fr
Dynare project — http://www.dynare.org
Phone: +33 1 40 77 49 90
PGP Key: 0xA6C029B9D06B2913D71C105EBE37E801FB6EFF8B (http://pgp.mit.edu/)
extern "C"
{
  void exception_thrower();
}
#include <cstdio>

#include "mylib.h"

extern "C"
{
  void
  exception_thrower()
  {
    throw 0;
  }
}
#include <cstdio>

#include "mylib.h"

int
main(int argc, char **argv)
{
  try
    {
      exception_thrower();
    }
  catch (...)
    {
      printf("Catched!\n");
    }

  return 0;
}

Attachment: pgpKw29RrBQTa.pgp
Description: PGP signature

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to