Originally shared by Thomas Mueller (dummzeuch)

Originally shared by Thomas Mueller (dummzeuch)

Today I had a curious bug: After changing the way GPS coordinates were read from a file (not calculated!) all of a sudden lots of unrelated floating point calculations had different results. I reverted the changes just to be sure and, yes, the results…
http://blog.dummzeuch.de/2018/09/06/if-your-floating-point-calculations-differ-after-a-trivial-change/

Comments

  1. This is a problem with the old MS C++ Compilers. Not only on loading, it can also happen in a call to a Dll func. In our code we have lot of calls to fix that after a call. It can be a nightmare.

    ReplyDelete
  2. Reminds the "fun" with printer drivers....

    ReplyDelete
  3. I wrote about this a while ago. There are some other issues as well. We had to chase this and other things down in CrossTalk about 10 years ago and it was a real bugger to figure out at the time.

    ReplyDelete
  4. Also can be an issue when you write code that is compiled into a dll. Do you want your code changing the FPU state and impacting the host's code?

    ReplyDelete
  5. I'm still mulling on how changing back the control word will affect the calculation in the functions of this DLL. And how this affects multiple threads is also an unknown to me so far.

    ReplyDelete
  6. Thomas Mueller I tend to set the control word to MS default before calling into third party DLLs. Then restore it when they return.

    Threading is made more difficult because Set8087CW is not threadsafe.

    I use a modified version (runtime code patching) of the RTL to fix many issues relating to FPU state.

    ReplyDelete
  7. David Heffernan is that code available on-line somewhere for the public at large?

    ReplyDelete
  8. Jeroen Wiert Pluimers the details are in one of my QC reports, but it's very messy.

    ReplyDelete
  9. David Heffernan thanks. If you have the QC number, let us know.

    ReplyDelete
  10. Jeroen Wiert Pluimers, is the QC still online? I thought it was closed last year.

    ReplyDelete
  11. Leif Uneus I downloaded most of the ClientDataSet data (without attachments: it went down before I could try downloading them). Uwe Raabe created the QCScraper tool to do that: https://www.uweraabe.de/Blog/2017/06/09/how-to-save-qualitycentral/

    ReplyDelete
  12. Jeroen Wiert Pluimers Yes, I downloaded that last year, but there are no attachments as you know. Anyway, the report you are looking for is probably QC107411 "Suggested re-design of RTL management of floating point control words"", and the zip file name is "Rethinking Delphi Floating Point Control Register Ma.zip". Note: it is stored with 7zip. I have the pdf here and can upload it to you if you like.

    ReplyDelete
  13. Leif Uneus yeah that's it, and my product OrcaFlex is built with that technique applied

    ReplyDelete
  14. Leif Uneus uploading the PDF would be nice. As the attachment is not in the archive spree that I initiated late 2017. web.archive.org - QualityCentral

    ReplyDelete

Post a Comment