Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4D-API_cs2cs-style.gie fails on Debian unstable (with GCC 8) #1084

Closed
sebastic opened this issue Aug 1, 2018 · 7 comments
Closed

4D-API_cs2cs-style.gie fails on Debian unstable (with GCC 8) #1084

sebastic opened this issue Aug 1, 2018 · 7 comments
Milestone

Comments

@sebastic
Copy link
Contributor

sebastic commented Aug 1, 2018

4D-API_cs2cs-style.gie started to fail on Debian unstable recently. Quite possibly related to GCC 8 becoming the default compiler.

-------------------------------------------------------------------------------
Reading file 'GDA.gie'
-------------------------------------------------------------------------------
total:  3 tests succeeded,  0 tests skipped,  0 tests failed.
-------------------------------------------------------------------------------
PROJ_LIB=../../nad ../../src/gie builtins.gie
-------------------------------------------------------------------------------
Reading file 'axisswap.gie'
-------------------------------------------------------------------------------
total: 27 tests succeeded,  0 tests skipped,  0 tests failed.
-------------------------------------------------------------------------------
PROJ_LIB=../../nad ../../src/gie deformation.gie
-------------------------------------------------------------------------------
Reading file '4D-API_cs2cs-style.gie'
     -----
     FAILURE in 4D-API_cs2cs-style.gie(114):
     expected: 12.5 55.5 0
     got:      inf   inf   inf
     deviation:  999999999.999000 mm,  expected:  150.000000 mm
-------------------------------------------------------------------------------
total: 28 tests succeeded,  0 tests skipped,  1 tests FAILED!
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Reading file 'deformation.gie'
-------------------------------------------------------------------------------
total: 37 tests succeeded,  0 tests skipped,  0 tests failed.
-------------------------------------------------------------------------------
make[5]: *** [Makefile:455: 4D-API-cs2cs-style] Error 1
make[5]: *** Waiting for unfinished jobs....
-------------------------------------------------------------------------------
Reading file 'builtins.gie'
-------------------------------------------------------------------------------
total: 1568 tests succeeded,  0 tests skipped,  0 tests failed.
-------------------------------------------------------------------------------
rouault added a commit to rouault/PROJ that referenced this issue Aug 10, 2018
torad_coord() of gie.c has this sequence:
```
if( cond )
    axis = l->param + strlen ("axis=");
n = strlen (axis);
```

When the if branch is evaluated, n is always zero
even if on inspection axis is non empty

The reason is that the struct ARG_list which is the
type of l use a variable-length array for the param member

struct ARG_list {
    paralist *next;
    char used;
    char param[1];
};

But this is not a proper way of declaring it, and
gcc 8 has apparently optimizations to detect that l->param + 5
points out of the array, hence it optimizes strlen() to 0.

According to https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html,
the proper way of declaring such arrays is to use [0]
rouault added a commit that referenced this issue Aug 11, 2018
Fix wrong behaviour of torad_coord() with gcc 8.1 -O2 (fixes #1084)
@rouault rouault added this to the 5.2.0 milestone Aug 11, 2018
@rouault
Copy link
Member

rouault commented Aug 11, 2018

@sebastic. Fixed. I suspect a gcc optimization bug (reported as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86914 )

@sebastic
Copy link
Contributor Author

Thanks for the patch and in-depth analysis. I've included the changes from 143b4d3 as a patch in the 5.1.0 Debian package, but the test still fails in the same way:

make[5]: Entering directory '/build/proj-5.1.0/test/gie'
PROJ_LIB=../../nad ../../src/gie 4D-API_cs2cs-style.gie
PROJ_LIB=../../nad ../../src/gie GDA.gie
PROJ_LIB=../../nad ../../src/gie axisswap.gie
-------------------------------------------------------------------------------
Reading file 'GDA.gie'
-------------------------------------------------------------------------------
total:  3 tests succeeded,  0 tests skipped,  0 tests failed.
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Reading file 'axisswap.gie'
-------------------------------------------------------------------------------
total: 27 tests succeeded,  0 tests skipped,  0 tests failed.
-------------------------------------------------------------------------------
PROJ_LIB=../../nad ../../src/gie builtins.gie
PROJ_LIB=../../nad ../../src/gie deformation.gie
-------------------------------------------------------------------------------
Reading file 'deformation.gie'
-------------------------------------------------------------------------------
total: 37 tests succeeded,  0 tests skipped,  0 tests failed.
-------------------------------------------------------------------------------
PROJ_LIB=../../nad ../../src/gie ellipsoid.gie
-------------------------------------------------------------------------------
Reading file '4D-API_cs2cs-style.gie'
     -----
     FAILURE in 4D-API_cs2cs-style.gie(114):
     expected: 12.5 55.5 0
     got:      inf   inf   inf
     deviation:  999999999.999000 mm,  expected:  150.000000 mm
-------------------------------------------------------------------------------
total: 28 tests succeeded,  0 tests skipped,  1 tests FAILED!
-------------------------------------------------------------------------------
make[5]: *** [Makefile:458: 4D-API-cs2cs-style] Error 1
make[5]: *** Waiting for unfinished jobs....
-------------------------------------------------------------------------------
Reading file 'ellipsoid.gie'
-------------------------------------------------------------------------------
total: 30 tests succeeded,  0 tests skipped,  0 tests failed.
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Reading file 'builtins.gie'
-------------------------------------------------------------------------------
total: 1568 tests succeeded,  0 tests skipped,  0 tests failed.
-------------------------------------------------------------------------------
make[5]: Leaving directory '/build/proj-5.1.0/test/gie'

Full buildlog: proj_5.1.0-2_amd64.txt

@rouault
Copy link
Member

rouault commented Aug 11, 2018

@sebastic Weird. Can you just try to build master and make check (after installing egm96_15.gtx in nad/) with the same compiler ?

@sebastic
Copy link
Contributor Author

make check on master has two failures:

make[3]: Entering directory '/home/bas/git/OSGeo/proj/test/gie'
PROJ_LIB=../../nad ../../src/gie 4D-API_cs2cs-style.gie
-------------------------------------------------------------------------------
Reading file '4D-API_cs2cs-style.gie'
     -----
     FAILURE in 4D-API_cs2cs-style.gie(114):
     expected: 12.5 55.5 0
     got:      inf   inf   inf
     deviation:  999999999.999000 mm,  expected:  150.000000 mm
     -----
     FAILURE in 4D-API_cs2cs-style.gie(256):
     expected: -100.0004058367 40.0000058947 0.0000
     got:      -100.000000000000   40.000000000000
     deviation:  34662.139691 mm,  expected:  200.000000 mm
-------------------------------------------------------------------------------
total: 35 tests succeeded,  2 tests skipped,  2 tests FAILED!
-------------------------------------------------------------------------------
make[3]: *** [Makefile:466: 4D-API-cs2cs-style] Error 2

@rouault
Copy link
Member

rouault commented Aug 11, 2018

OK, I can reproduce within a Debian unstable VM with gcc 8.2. Regarding the first failure initially reported (4D-API_cs2cs-style.gie(114)), this is a difference between gcc 8.1 and 8.2, and the later only generates the correct code if using the [] syntax (I've updated https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86914 with it). Investigating for the new issue: 4D-API_cs2cs-style.gie(256)

@rouault rouault reopened this Aug 11, 2018
@rouault
Copy link
Member

rouault commented Aug 11, 2018

@sebastic First test failure fixed per edfa298
Second failure was unrelated to the GCC version but to the lack of the conus grid. Fixed per 666efb9

@sebastic
Copy link
Contributor Author

Confirmed fixed with the changes from edfa298, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants