Opened 3 years ago

Closed 3 years ago

#4872 closed defect (fixed)

Failure on windows - wkt_input

Reported by: robe Owned by: pramsey
Priority: blocker Milestone: PostGIS 3.2.0
Component: postgis Version: master
Keywords: Cc:


I vaguely remember this failing beofre and Raul did something:

-------------- Dependencies -------------- 
  GEOS config:          /projects/geos/rel-3.9w64gcc81/bin/geos-config
  GEOS version:         3.9.2dev
  GDAL config:          /projects/gdal/rel-3.2.1w64gcc81/bin/gdal-config
  GDAL version:         3.2.1
  SFCGAL config:        /projects/CGAL/rel-sfcgal-1.3.9w64gcc81/bin/sfcgal-config
  SFCGAL version:       1.3.8
  PostgreSQL config:    /projects/postgresql/rel/pg11w64gcc81/bin/pg_config
  PostgreSQL version:   PostgreSQL 11.2
  PROJ4 version:        71
  Libxml2 config:       /projects/libxml/rel-libxml2-2.9.9w64gcc81/bin/xml2-config
  Libxml2 version:      2.9.9
  JSON-C support:       yes
  protobuf support:     yes
  protobuf-c version:   1002001
  PCRE support:         yes
  Perl:                 /usr/bin/perl

 --------------- Extensions --------------- 
Suite: wkt_input
  Test: test_wkt_in_point ...FAILED
    1. cu_in_wkt.c:108  - CU_ASSERT_STRING_EQUAL(r,s)

I'm not sure how long this has been broken because build has been broken because of GEOS 3.10 issue I am having compiling so I flipped to 3.9dev.

Change History (5)

comment:1 by robe, 3 years ago

I added a printf to see the difference and this is what I get

IN:  point(nan 10)
OUT: point(0 10)

What to do?

comment:2 by pramsey, 3 years ago

So, for "reasons" the dtof() function is converting "nan" to 0? Seems like? I guess you could start confirming that by adding a little test up front, make sure what we're seeing is just a straight-up oddness in windows?

s = "nan";
s = "point(nan 10)";
r = cu_wkt_in(s, WKT_ISO);

comment:3 by robe, 3 years ago

  Test: test_wkt_in_point ...FAILED
    1. cu_in_wkt.c:106  - isnan(atof(s))
    2. cu_in_wkt.c:110  - CU_ASSERT_STRING_EQUAL(r,s)
    3. cu_in_wkt.c:116  - CU_ASSERT_STRING_EQUAL(r,s)

comment:4 by pramsey, 3 years ago

Here's a patch which should fix your installation and doesn't seem to break mine

diff --git a/liblwgeom/lwin_wkt_lex.l b/liblwgeom/lwin_wkt_lex.l
index 273a97966..d301a2259 100644
--- a/liblwgeom/lwin_wkt_lex.l
+++ b/liblwgeom/lwin_wkt_lex.l
@@ -34,6 +34,17 @@ static void wkt_lexer_unknown()
        LWDEBUGF(5,"lex: %s", wkt_yytext); \
        } while (0);
+* Ensure we have a definition of NAN to use when encountering
+* NAN tokens.
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#include <math.h>
+#ifndef NAN
+#define NAN 0.0/0.0
@@ -57,7 +68,7 @@ static void wkt_lexer_unknown()
 ([Nn][Aa][Nn])[ \,\)\t\n\r] {
        LWDEBUG(5,"DOUBLE NAN");
-       wkt_yylval.doublevalue = atof(wkt_yytext);
+       wkt_yylval.doublevalue = NAN;
        return DOUBLE_TOK;

comment:5 by Regina Obe <lr@…>, 3 years ago

Resolution: fixed
Status: newclosed

In 2a73173e/git:

fix from pramsey for NaN on mingw64. Closes #4872

Note: See TracTickets for help on using tickets.