I wrote a dll with MS Visual Studio 2012 and, from my Delphi application (written with Tokyo 10.2.2) I link it dynamically by LoadLibrary and GetProcAddress.
I wrote a dll with MS Visual Studio 2012 and, from my Delphi application (written with Tokyo 10.2.2) I link it dynamically by LoadLibrary and GetProcAddress.
The dll is a "wrapper/bridge" from a closed source .lib and my Delphi app.
When application start-up call some exported function inside the .dll and sometimes I get the EInvalidOp exception.
"Sometimes" means... 1 every 10 runs, but also 1 every 800 runs.
To test it I wrote another program that run and close my Delphi app continuasly.
By Madexcept I saw where the code that raise exception and I tried to catch by try..except statement in Delphi and also try..catch on dll side but without effect, I get always the same exception.
I read on EMB docs that "EInvalidOp is raised when the CPU encounters an undefined instruction, invalid operation, or floating-point stack overflow."
...and I also read that the cause (may be) a different FPU?
That's could be the right way?
(I have not tried this yet)
Set8087CW($133f); // Disable all fpu exceptions
Thanks to everybody.
The dll is a "wrapper/bridge" from a closed source .lib and my Delphi app.
When application start-up call some exported function inside the .dll and sometimes I get the EInvalidOp exception.
"Sometimes" means... 1 every 10 runs, but also 1 every 800 runs.
To test it I wrote another program that run and close my Delphi app continuasly.
By Madexcept I saw where the code that raise exception and I tried to catch by try..except statement in Delphi and also try..catch on dll side but without effect, I get always the same exception.
I read on EMB docs that "EInvalidOp is raised when the CPU encounters an undefined instruction, invalid operation, or floating-point stack overflow."
...and I also read that the cause (may be) a different FPU?
That's could be the right way?
(I have not tried this yet)
Set8087CW($133f); // Disable all fpu exceptions
Thanks to everybody.
Thomas Mueller I wrote a very simple Delphi demo to reproduce and isolate the problem, and the dll give me back an only integer.
ReplyDeleteYes, all stdcall.
Lars Fosdal why CoInitialize? My dll isn't a COM object.
Below, the my dll C code that I call from my Delphi demo.
Here some info:
https://github.com/CoolProp/CoolProp/issues/892
https://plus.google.com/photos/...
IT SEEMS TRUE, I found another Delphi example release by MvTec (a German company that builds "machine vision" software) which release a C, C++ and C# library.
ReplyDelete// The HALCON library has been generated with VisualC which
// expects overflow and underflow exceptions to be disabled.
// Set the FPU control register accordingly.
Set8087CW($27f);
Tomorrow I'll add this instructions on my demo and ... run again a lot of times.
I need to investigate what is the right number to pass at Set8087CW function.
Any other comments / suggestions will be appreciated.
Anyway, thanks a lot for your fast and kind replies!