Opened 20 years ago

Closed 19 years ago

#665 closed defect (worksforme)

mapserver crashes when having null values in dbf

Reported by: bartvde@… Owned by: dmorissette
Priority: high Milestone: 4.2 release
Component: MapServer CGI Version: 4.2
Severity: normal Keywords:
Cc:

Description

bartvde@xs4all.nl wrote:
> Hi list,
> 
> I am using a shapefile as a datasource and I am classifying this shapefile
> on a column named Perc.
> 
> Perc < 90.0 then red
> Perc > 90.0 then green
> 
> Now my dbf column Perc has null values which makes Mapserver crash when
> issuing a WMS GetMap request.
> 
> Is there anyway to use a classification on a column which contains null
> values?
> 
> [Fri May 14 13:53:42 2004] [error] [client 192.168.3.4] Premature end of
> script headers: mapserv_42.exe
> 

I didn't know you could have null values in a DBF... could you please 
file a bug with a sample file to reproduce?

If you get the bug in quick enough and it's a simple fix then it might 
make it in 4.2beta3

Attachments (1)

bug665.tgz (45.8 KB ) - added by bartvde@… 20 years ago.
shapefile and mapfile illustrating the bug (tar.gz format)

Download all attachments as: .zip

Change History (10)

by bartvde@…, 20 years ago

Attachment: bug665.tgz added

shapefile and mapfile illustrating the bug (tar.gz format)

comment:1 by dmorissette, 20 years ago

Cc: warmerdam@… steve.lime@… added
Owner: changed from sdlime to morissette@…
I'll have a look before tagging the 4.2beta3 source.

Adding Frank to the CC in case he knows something about this already (as the
shapelib maintainer)

comment:2 by dmorissette, 20 years ago

attachments.description: shapefile and mapfile illustrating the bugshapefile and mapfile illustrating the bug (tar.gz format)

comment:3 by fwarmerdam, 20 years ago

The shapelib test looks like this:


int SHPAPI_CALL
DBFIsAttributeNULL( DBFHandle psDBF, int iRecord, int iField )

{
    const char	*pszValue;

    pszValue = DBFReadStringAttribute( psDBF, iRecord, iField );

    if( pszValue == NULL )
        return TRUE;

    switch(psDBF->pachFieldType[iField])
    {
      case 'N':
      case 'F':
        /* NULL numeric fields have value "****************" */
        return pszValue[0] == '*';

      case 'D':
        /* NULL date fields have value "00000000" */
        return strncmp(pszValue,"00000000",8) == 0;

      case 'L':
        /* NULL boolean fields have value "?" */ 
        return pszValue[0] == '?';

      default:
        /* empty string fields are considered NULL */
        return strlen(pszValue) == 0;
    }
}

comment:4 by dmorissette, 20 years ago

Status: newassigned
I've been unable to reproduce the crash on Linux by doing a GetMap on your
mapfile/layer (after fixing it a bit). Even Valgrind doesn't report any issue.

I suspect that there would be a printf("%s", NULL) somewhere (this is know to
work on some machines and crash on others)

Anyway, I'll keep trying to track this, but I have already tagged the source for
rel-4-2-0-beta3 so this fix may not make it in the beta3.

comment:5 by dmorissette, 20 years ago

Cc: assefa@… added
Resolution: worksforme
Status: assignedclosed
I'm still unable to reproduce...

I see that the value received by msLayerNextShape() for field J2000 in shape #1
(the second record) is "****************" , which corresponds to the definition
of null in Frank's code, but that's not a C NULL, and there doesn't seem to be
any code in map*.c that does anything special with this attribute value... so I
don't think I can do much without a better way to reproduce.

Bart: Are you sure that the mapfile/data that you sent reproduces the crash? The
mapfile you sent didn't work out of the box, for instance the attribute "Perc"
doesn't exist in the data you sent so I changed your expressions to use J2000.
Also, are you working against the latest 4.2 source?


comment:6 by dmorissette, 20 years ago

Resolution: worksforme
Status: closedreopened

comment:7 by dmorissette, 20 years ago

Milestone: 4.2 release

comment:8 by bartvde@…, 20 years ago

Hi Daniel,

I have just verified my testcase and you're right I did not adapt my column name 
in the expression, sorry for that.

I have setup a WMS layer on my Windows webserver, one which is classified on 
J2000 which has the null values, and one which is classified on J2015 which does 
not contain null values.

// classified on J2015, works:
http://www.vz.geodan.nl:1112/cgi-bin/mapserv_42.exe?
map=/ms4w_20/apps/test/map/test.
map&request=GetMap&layers=bon_regio_vlak_2015&format=image/png&srs=EPSG:
28992&bbox=100000,350000,200000,450000&width=500&height=500&version=1.1.1

// classified on J2000, does not work, internal server error:
http://www.vz.geodan.nl:1112/cgi-bin/mapserv_42.exe?
map=/ms4w_20/apps/test/map/test.
map&request=GetMap&layers=bon_regio_vlak_2000&format=image/png&srs=EPSG:
28992&bbox=100000,350000,200000,450000&width=500&height=500&version=1.1.1

I am using mapserver_42.exe from May 4th 2004. Maybe this is specific for 
Windows again?

My new MAP file (at least the LAYERs section):

  LAYER
      DATA "bonregio-oppervlak"
        METADATA
          WMS_TITLE "BON regio 2000"
          WMS_ABSTRACT "BON regio 2000"
          WMS_SRS "EPSG:28992"
          WFS_TITLE "BON regio 2000"
        END
      NAME "bon_regio_vlak_2000"
      SIZEUNITS PIXELS
      STATUS ON
      TOLERANCE 0
      TOLERANCEUNITS PIXELS
      TYPE POLYGON
      DUMP TRUE
      TEMPLATE "blank.html"
      UNITS METERS
      CLASSITEM "J2000"
      CLASS
        NAME "slecht"
        EXPRESSION ([J2000] < 90)
        COLOR 255 0 0
        OUTLINECOLOR 0 0 0
      END
      CLASS
        NAME "goed"
        EXPRESSION ([J2000] > 90)
        COLOR 0 255 0
        OUTLINECOLOR 0 0 0
      END
    END

  LAYER
      DATA "bonregio-oppervlak"
        METADATA
          WMS_TITLE "BON regio 2015"
          WMS_ABSTRACT "BON regio 2015"
          WMS_SRS "EPSG:28992"
          WFS_TITLE "BON regio 2015"
        END
      NAME "bon_regio_vlak_2015"
      SIZEUNITS PIXELS
      STATUS ON
      TOLERANCE 0
      TOLERANCEUNITS PIXELS
      TYPE POLYGON
      DUMP TRUE
      TEMPLATE "blank.html"
      UNITS METERS
      CLASSITEM "J2015"
      CLASS
        NAME "slecht"
        EXPRESSION ([J2015] < 90)
        COLOR 255 0 0
        OUTLINECOLOR 0 0 0
      END
      CLASS
        NAME "goed"
        EXPRESSION ([J2015] > 90)
        COLOR 0 255 0
        OUTLINECOLOR 0 0 0
      END
    END

comment:9 by bartvde@…, 19 years ago

Resolution: worksforme
Status: reopenedclosed
I just tested this one again with Mapserver 4.4.1 on Windows and was unable to
reproduce. Closing this bug therefore.
Note: See TracTickets for help on using tickets.