Registered Member
|
Hi,
This seemed too weird to me, so I thought I should ask if anybody knows why ? I have a code which can be compiled with Visual Studio C++ 2010 as a DLL and it works in Excel VBA. But if I compile the same exact code using gcc it causes a crash in Excel. This is basically the snippet of the code that causes the crash:
This code causes the VBA/Excel to crash. But, if I comment out the last line of this code, then DLL will not crash when called from VBA, and it works nicely. So the crash has something to do with matrix multiplication. I don't know why it works with Visual Studio 2010, but not with g++ 4.6.2 ? This is the g++ command I use:
Thanks, Mehrdad |
Moderator
|
|
Moderator
|
oh wait, again by gcc I guess you meant mingw, then change the -O3 to -O2. See: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556
|
Registered Member
|
Followed instructions here:
http://eigen.tuxfamily.org/dox/TopicWro ... nment.html and it seemed to fix it. Still would have preferred to make it work (since I used to compile the same code with g++ 4.6.2 as a DLL successfully for 'R', but now, it wasn't working for VBA). |
Registered Member
|
Thanks gael, yes I meant mingw (and I would have gladly provided backtrace if I knew how - especially since it's a dll called from VBA)
Anyway, I actually tried that, and changed -O3 to -O2 but it was still crashing. I even added -fno-ipa-cp-clone and it still crashed. It was only adding -mstackrealign which worked without a crash. |
Moderator
|
Are you saying that adding -mstackrealign fixed your issue? Makes sense now because matrix products are allocating some temporaries on the stack with alloca but since by default mingw does not keep an aligned stack, alloca failed to returned an aligned buffer. -mstackrealign is a good workaround, but that's also easy to fix upstream.
|
Moderator
|
hm, no that's strange because alloca is only used if __linux__ or _MSC_VER are defined. That should not be the case with mingw. Could you check whether EIGEN_ALLOCA is defined after including eigen, e.g.:
thanks. |
Registered Member
|
hmmm.
I might have confused myself. The crash on Matrix product was happening in gcc 4.6.3. Let me give more background. During the time I was looking for a solution, I installed mingw 4.6.2 (I guess the newest version), and now I can see that it will crash even without the matrix product (I guess some other lines that were OK are now causing a crash). I also noticed that using -mstackrealign my VBA dll runs ok. However, there is a caveat. Upon closing the Excel sheet, there is this error message from Excel "This application has requested the Runtime to terminate it in an unusual way", which I think has to do with the DLL being unloaded unsuccessfully. So, I switched back to the older version of on my PC (gcc 4.6.3 that I had), and noticed that it is indeed the matrix product, alone that causes a crash, and using -mstackrealign (I actually used __attribute__((force_align_arg_pointer)) ), then the DLL works correctly, and when I close Excel that error message doesn't show up anymore and DLL gets unloaded successfully. And I have not defined EIGEN_ALLOCA when compiling my code, neither have I defined it anywhere in my code. I tried that piece of code u gave in previous post, and I didn't get any error. So it's not defined. I will dig in more I guess to see if I can get more information about it. |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]