On 9/8/2010 23:34, Mario Emmenlauer wrote:
>
> Hi,
>
>> On 9/8/2010 21:26, Sébastien Villemot wrote:
>>> Hi,
>>>
>>> Some extra information on the problem that I described in my previous
>>> post, and
>>> which I suspect to be a bug in MinGW-w64 for 64-bit platform.
>>>
>>> I attach a sample testcase, which I compile with:
>>>
>>> x86_64-w64-mingw32-gcc -g -O2 -fexceptions -Wall -shared
>>> -I~/MATLAB/extern/include mextest.c -o mextest.mexw64
>>> -L~MATLAB/bin/win64 -lmex
>>>
>>> The libmex.dll contains both mexErrMsgTxt() and mexPrintf().
>>>
>>> As such, the example makes MATLAB crash.
>>>
>>> But if I comment out the second function call (mexPrintf()), then the
>>> DLL
>>> behaves as expected: MATLAB catches the exception thrown by
>>> mexErrMsgTxt(), and
>>> displays the error message.
>>>
>>> It is very strangs since having or not the mexPrintf() should not change
>>> the
>>> result, since it is never reached.
>>>
>>> So it looks like a compiler bug, unless I’m missing something ? I’m
>>> not
>>> familiar with exception unwinding, so please forgive my ignorance.
>>>
>>> Any idea ?
>>>
>>> Best regards,
>>
>> Hi,
>>
>> sorry for the lack of responses, its hard to know what is wrong when
>> nobody is familiar with Matlab internals.
>>
>> How exactly is a matlab exception thrown and caught anyway?
>
> Please excuse my ignorance, I just read the subject and not the details
> but I would like to note that throwing/catching exceptions between DSO's
> (dynamically linked objects) can be very tricky with gcc, see
>     http://gcc.gnu.org/wiki/Visibility
>
> esp. the Section "Problems with C++ exceptions"
>
> I couldn't get exceptions to work between DSO's _at_all_ when the
> exceptions where defined in a static library. So you might want to
> take a close look before using them. Hope this is useful, and if not,
> please forgive my ignorance!
>

OP says the DLL is C code. Exception doesn't automatically mean C++.

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to