ArcGIS runtime errors after upgrading from Delphi 2007 to Delphi XE3

We have an application written in Delphi Pascal that accesses the ArcGIS 9.3 API through the COM interface. We recently upgraded from Delphi 2007 to Delphi XE3 and ever since we upgraded we have been getting runtime errors in the ArcGIS libraries that we were not getting before.
Specifically the error is always "invalid floating point operation".
The first one that was occurring was happening in the method "sg.SgCoordRefSetZ". I was able to eliminate this error by adding a call to FGeoSpatialReference.SetZDomain(-10000, 100000.0) even though there is nowhere that we're using Z coordinates.
The second one I found was caused by adding features to a feature class without a geometry defined. For that I simply tested for an empty geometry and didn't add the feature if the geometry was nil.
I have a new one that's occurring in the same bit of code as the first one (i.e. "sg.SgCoordRefSetZ") but it happens when I call FMapControl.LoadMxFile(MapDocumentFileName); There is no way I can trace this.
The confusing part, and my question, is why are these errors happening after upgrading Delphi from 2007 to XE3 and not before.
I'm writing this out of frustration and desperation, so if I come across as being frustrated or desperate, that's why.
0
Thomas
2/23/2013 12:33:10 AM
📁 embarcadero.delphi.ole
📃 598 articles.
⭐ 1 followers.

💬 2 Replies
👁️‍🗨️ 1686 Views


Thomas Bates wrote:
> We have an application written in Delphi Pascal that accesses the
> ArcGIS 9.3 API through the COM interface. We recently upgraded from
> Delphi 2007 to Delphi XE3 and ever since we upgraded we have been
> getting runtime errors in the ArcGIS libraries that we were not
> getting before.
> 
> Specifically the error is always "invalid floating point operation".
> 
> The first one that was occurring was happening in the method
> "sg.SgCoordRefSetZ". I was able to eliminate this error by adding a
> call to FGeoSpatialReference.SetZDomain(-10000, 100000.0) even though
> there is nowhere that we're using Z coordinates.
> 
> The second one I found was caused by adding features to a feature
> class without a geometry defined. For that I simply tested for an
> empty geometry and didn't add the feature if the geometry was nil.
> 
> I have a new one that's occurring in the same bit of code as the
> first one (i.e. "sg.SgCoordRefSetZ") but it happens when I call
> FMapControl.LoadMxFile(MapDocumentFileName); There is no way I can
> trace this.
> 
> The confusing part, and my question, is why are these errors
> happening after upgrading Delphi from 2007 to XE3 and not before.
There are two sources of these FPU errors i'm aware of:
 - using uninitialized floating-point variables. Such variables may
then contain bit patterns that correspond to a NaN or Inf value by
chance, which can cause errors when they are used, especially by an
external library.
 - the settings of the FPU control word. THis has always been a sore
point when using external libraries, since those may make assumptions
about how the FPU flags are set which the Delphi side does not match. I
don't know whether the Delphi RTL default has changed in this area
between D2007 and XE3, but it would explain the differences you see
between the versions.
Search Google or codenewsfast.com for Set8087CW, that should turn up a
lot of threads for related problems.
Also check the docs for the COM object you are using, perhaps you can
find the expected settings for the control word there.

-- 
Peter Below (TeamB)
0
Peter
2/23/2013 8:45:22 AM
> {quote:title=Peter Below wrote:}{quote}
> Thomas Bates wrote:
> 
> > We have an application written in Delphi Pascal that accesses the
> > ArcGIS 9.3 API through the COM interface. We recently upgraded from
> > Delphi 2007 to Delphi XE3 and ever since we upgraded we have been
> > getting runtime errors in the ArcGIS libraries that we were not
> > getting before.
> > 
> > Specifically the error is always "invalid floating point operation".
> > 
> > The first one that was occurring was happening in the method
> > "sg.SgCoordRefSetZ". I was able to eliminate this error by adding a
> > call to FGeoSpatialReference.SetZDomain(-10000, 100000.0) even though
> > there is nowhere that we're using Z coordinates.
> > 
> > The second one I found was caused by adding features to a feature
> > class without a geometry defined. For that I simply tested for an
> > empty geometry and didn't add the feature if the geometry was nil.
> > 
> > I have a new one that's occurring in the same bit of code as the
> > first one (i.e. "sg.SgCoordRefSetZ") but it happens when I call
> > FMapControl.LoadMxFile(MapDocumentFileName); There is no way I can
> > trace this.
> > 
> > The confusing part, and my question, is why are these errors
> > happening after upgrading Delphi from 2007 to XE3 and not before.
> 
> There are two sources of these FPU errors i'm aware of:
> 
>  - using uninitialized floating-point variables. Such variables may
> then contain bit patterns that correspond to a NaN or Inf value by
> chance, which can cause errors when they are used, especially by an
> external library.
> 
>  - the settings of the FPU control word. THis has always been a sore
> point when using external libraries, since those may make assumptions
> about how the FPU flags are set which the Delphi side does not match. I
> don't know whether the Delphi RTL default has changed in this area
> between D2007 and XE3, but it would explain the differences you see
> between the versions.
> 
> Search Google or codenewsfast.com for Set8087CW, that should turn up a
> lot of threads for related problems.
> Also check the docs for the COM object you are using, perhaps you can
> find the expected settings for the control word there.
> 
> 
> -- 
> Peter Below (TeamB)
Thank you, Peter, that did the trick.
However, when I looked up the Set8087CW call on the Embarcadero site, it suggested using System.Math.SetExceptionMask instead, so I did.  
Thomas Bates
0
Thomas
11/28/2013 9:57:35 PM
Reply: