Faced the C library ( proj4 ), which, when initialized, generates itself NaN :

NaN = sqrt(-1.0); (see geodesic.c )

I use this library from Delphi and there from such a trick falls out the exception "Floating point invalid operation" .

With this exception, in principle, it is possible to fight, but the method is not thread-safe (the global variable Default8087CW used within the Delphi system libraries):

  var VMask: TArithmeticExceptionMask; begin VMask := GetExceptionMask(); SetExceptionMask(VMask + [exInvalidOp]); try // вызов функции, которая бросает исключение finally SetExceptionMask(VMask); end; end; 

I collected this library ( proj.dll ) myself from sorts, in MSVC 2008, and maybe I didn’t correctly indicate any flags when compiling that affect forwarding of this exception?

Tell me, did anyone come across such a situation and how can it be dealt with normally in a multithreaded application.

  • And why not to conclude Try.. Except and catch exactly this type of exception? So much for thread safety. - kami
  • @kami If an exception occurs in the code, then its execution is interrupted and the library does not fully execute all of its initializations. Therefore, you just need to disable the generation of an exception so that all the code in the library runs to the end. - zed
  • So if the code was interrupted directly inside the dll on c , then how would it help you to ignore the exception already in Delphi , outside the interrupted code? You cannot restore the initialization anymore ... In this case, I do not understand the meaning of the code given by you in the question. - kami
  • @kami so the code in the dll not interrupted. This is not ignoring, but disabling an exception that is executed through the registers of the processor, and not just in Delphi . - zed
  • Yeah, I saw. Thank you, did not know about this opportunity. - kami

0