OSGeo / PROJ

PROJ - Cartographic Projections and Coordinate Transformations Library
https://proj.org
Other
1.7k stars 771 forks source link

proj gie tests using adams_ws2.gie fail on macOS 13.3+ #3714

Open gaige opened 1 year ago

gaige commented 1 year ago

This is an odd one. It looks like something changed in the math libraries in macOS 13.3+ that results in a large enough change in accuracy to cause tests for adams ws2 to fail.

Example of problem

Running gie using adams_ws2.gie on macOS 13.3.1 fails, even if the gie binary was built months ago. Same test run on macOS 13.2 (with the identical binaries) succeed. NOTE this same test works fine on Apple Silicon CPUs, but fails on x86_64 CPUs. Regression testing through macOS 12 and macOS 11 indicate no similar problem on those with the same binary.

Minimal test case with a small .gie file is:

<gie-strict>

-------------------------------------------------------------------------------
# Test inverse
-------------------------------------------------------------------------------
operation +proj=adams_ws2 +ellps=WGS84
-------------------------------------------------------------------------------
direction forward
tolerance 1 mm

accept    -179.999     -89.999
expect    -693320.704  -16030515.906
roundtrip  1

direction  inverse
accept     0.000005801264 16722285.492330472916
expect     failure  errno coord_transfm_outside_projection_domain

</gie-strict>

Output:

Debug % ./gie -vvvv test.gie                            
-------------------------------------------------------------------------------
Reading file 'test.gie'
-------------------------------------------------------------------------------
proj=adams_ws2 ellps=WGS84                                            
#  -179.999 -89.999
NOT INVERTED
forward
angular in
linear out
left: 4   right:  1
EXPECTS  -693320.704000000027  -16030515.905999999493  0.000000000000  0.000000000000
ACCEPTS  -3.141575200297  -1.570778873502  0.000000000000  0.000000000000
GOT      -693320.703926938935  -16030515.905885625631  0.000000000000  0.000000000000
-------------------------------------------------------------------------------
     FAILURE in test.gie(15):
     roundtrip deviation: inf mm, expected: 1.000000 mm
#  0.000005801264 16722285.492330472916
-------------------------------------------------------------------------------
total:  2 tests succeeded,  0 tests skipped,  1 tests FAILED!
-------------------------------------------------------------------------------
Failing roundtrips:    1,    Succeeding roundtrips:    0
Failing failures:      0,    Succeeding failures:      1
Internal counters:                            0001(0001)
-------------------------------------------------------------------------------

Using proj only:

 ./proj +proj=adams_ws2 +ellps=WGS84 -f "%.9f" -I
-693320.704  -16030515.906
*   *

Problem description

The expectation here is that the original test was appropriate, and that 1e-10 and 15 rounds are appropriate convergence parameters for the inverse. By increasing the maximum number of rounds to 18 or decreasing the accuracy requirement to 1e-8, the convergence happens on the Intel CPUs as well as ARM and under all OSs.

Expected Output

With the original test:

Debug % ./gie ../../../../Proj4/proj/test/gie/adams_ws2.gie
-------------------------------------------------------------------------------
Reading file '../../../../Proj4/proj/test/gie/adams_ws2.gie'
-------------------------------------------------------------------------------
total: 724 tests succeeded,  0 tests skipped,  0 tests failed.
-------------------------------------------------------------------------------

With the above isolation:

Debug % ./gie ~/test.gie                                   
-------------------------------------------------------------------------------
Reading file '/Users/buildbot/test.gie'
-------------------------------------------------------------------------------
total:  3 tests succeeded,  0 tests skipped,  0 tests failed.

Using proj only:

./proj +proj=adams_ws2 +ellps=WGS84 -f "%.9f" -I
-693320.704  -16030515.906
-179.999001378  -89.999000000

Environment Information

Installation method

phraemer commented 1 year ago

I found this issue while searching for other people experiencing weird float issues with Xcode 14.3 There is a small chance it's related to my issue too so linking here just in case:

https://forum.juce.com/t/xcode-14-3-compiler-bug/56130/5

ValeZAA commented 1 year ago

https://core-math.gitlabpages.inria.fr/ try linking against this standard library.