queryByAttributes & PostGIS PHP/Mapscript issue/crash/segfault

Rhys Ickeringill rhysi at OMNILINK.COM.AU
Wed May 18 01:07:30 EDT 2005


Results from further testing added below.

----- Original Message -----
From: "Rhys Ickeringill" <rhysi at OMNILINK.COM.AU>
To: <MAPSERVER-DEV at LISTS.UMN.EDU>
Sent: Tuesday, May 17, 2005 5:54 PM
Subject: [UMN_MAPSERVER-DEV] queryByAttributes PHP/Mapscript issue


> Hi dev-list,
>
> I'm attempting to do a pretty basic attribute search on a layer and am
> getting MapServer crashes. Should I file this as a bug or am I just doing
> something wrong?
>
> Data config:
> ~~~~~~~~~
> Postgres 7.4.7
> PostGIS 1.0.0
> PostGIS table 'parks' : CREATE TABLE parks ( ogc_fid integer NOT NULL,
> wkb_geometry geometry, name character(50) )
>
> System Config:
> ~~~~~~~~~~~
> Linux (Slackware 10.1)
> Apache 1.3.33
> PHP 4.3.10 (running as Apache DSO)
> MapServer 4.4.1 (runninng as PHP module)
>
>
> My map file looks like this:
>
> MAP "Map"
>     #
>     # Other layer definitions & map properties
>     #
>     LAYER
>         NAME "Parks"
>         TYPE polygon
>         CONNECTIONTYPE postgis
>         CONNECTION "dbname=mapdata"
>         DATA "wkb_geometry from parks using unique ogc_fid"
>         TEMPLATE "stub"
>         STATUS ON
>         PROJECTION
>             "prog=longlat"
>             "ellips=GRS80"
>         END
>         CLASS
>             NAME "Parks"
>             COLOR 0 160 0
>         END
>     END
>     #
>     # Other layer definitions...
>     #
> END
>
>
> The relevant PHP/MapScript code looks like this:
>
> ...
> if( array_key_exists('FID', $_REQUEST ) ){
>     $fid = $_REQUEST['FID'];
>     $layer = $map->getLayerByName( 'Parks' ); // does this OK
>     $qryResult = $layer->queryByAttributes( 'ogc_fid', $fid , MS_SINGLE )
//
> PHP processing dies here
>
>     if( $qryResult === MS_SUCCESS ){
>         // do stuff to highlight result and alter map extent (yet to be
> tested - never gets that far)
> ...
>
> I know it is the queryByAttributes() call which is causing the problem -
if
> I comment out the queryByAttributes() call, I get a pefectly drawn map
with
> the default [mapfile defined] extents.
>
> If I remove the TEMPLATE from the layer definition above, I get the
message:
>
> [MapServer Error] msQueryByAttributes(): Requested layer has no templates
> defined...
>
> This means processing is getting down to line 283 or so of mapquery.c.
> However I cannot find a way to raise the next error "No query expression
> defined" (line 286) - for example
>
> $layer->queryByAttributes( NULL, NULL, MS_SINGLE ).
>
> mysteriously dies the same way as before, as also MapServer does if I
> attempt to force the error "No matching record(s) found layer and area of
> interest do not overlap" from line 333 by fiddling with my map's extent.
>
> The only other information I have as to what is going wrong is found in
the
> Apache error log:
>
> *** glibc detected *** double free or corruption (!prev): 0x[some memory
> address] ***
> [some timstamp] [notice] child pid 1234 exit signal Aborted (6)
>

Have now found that this appears to be an error which only occurs using
PostGIS layers. If I alter my mapfile to use an OGR connection to load the
original MapInfo data, the exact same code which previously failed now
works. Switch back to PostGIS and it fails again.

I've tried changing the both the layer and column I'm querying, and
MapServer has consistantly failed in every situation where I use a PostGIS
datasource.

I'd switch to using MapInfo data format but it is too slow in certain
situations - hence why I spent the time using ogr2ogr to transform the data
into PostGIS format.

Anything I can do to quickly fix this? Or shall I start looking for ways to
work around this problem?

Also, should I submit all this as a bug report?


- Rhys



More information about the mapserver-dev mailing list