[mapserver-users] Need help tracking down mapserv seg fault

Johan Forsman Johan.Forsman at LA.GOV
Fri Aug 13 09:49:34 EDT 2010

Hello All:

Please pardon the very lengthy post. I have attempted to collect as much data as I could think of.

FGS95 with MapServer 5.4.1 on Ubuntu Server, using OGR JOIN results in mapserv seg fault when run from browser, works fine from shp2img.

I have an FGs95 install on Ubuntu Server 9.10, using MapServer 5.4.1 on the back with a mixed shapefile/PostGIS datastore, GeoMoose 2.2 front-end. Everything is working very nicely except for my current problem.

I have a need to color polygons stored in a shapefile, CLASSified based on attributes in an external csv-file. Guidance found in the ether indicates that the only way to do this with MapServer is to use an OGR connection between the shapefile and the csv-file.
Using tips found here and there I have been able to construct a SELECT statement in the DATA directive that allows shp2img to create a PNG that looks just like I hoped it would (see attached), but I must confess that I don't fully understand how as the SELECT statement does not look like what I am used to seeing in some proprietary products. I am clearly in need of an OGR education (with lots of example code).

The LAYER section in the mapfile is

LAYER # Parish Boundary Polygon Outline Layer
  NAME 'parishes_on_boiladv'
  CONNECTION "webmaps_parishes.shp"
  DATA "SELECT * FROM webmaps_parishes LEFT JOIN 'bwa.csv'.bwa ON webmaps_parishes.FIPS = bwa.FIPS"
  STATUS default
  TYPE polygon
  CLASSITEM "PercentageOut"
    EXPRESSION ([PercentageOut] > 0 AND [PercentageOut] <= 10)
    NAME "0 - 10%"
      COLOR 56 168 0
  END #class
(continues with several more classes).

The shapefile and csv-file are stored in the same directory. Both have a field "FIPS" which is the field I wish to join on. The "PercentageOut" field is in the csv-file. The DATA statement appears to work, but I looks really odd to me.

Is there a way to get a table output from the OGR JOIN to study?

I have set DEBUG 5 at the MAP level and the LAYER level to troubleshoot, but the process segfaults before any error is written to the ms_error file. The Apache and system logs contain only this when testing from localhost:

[Thu Aug 12 14:53:02 2010] [error] [client] Premature end of script headers: mapserv

Aug 12 14:53:02 geoview kernel: [12879514.857356] mapserv[24114]: segfault at 0 ip 0945e714 sp bf9058dc error 6

I saw another post with similar issues suggesting it's a library issue, discussing the LD_LIBRARY_PATH environment variable not being set properly for the Apache user. As far as I can tell this variable points to the right place in /opt/fgs/, but to be certain I added a SetEnv/PassEnv statement in the fgs-version of httpd.conf without any change in behavior.

In both /opt/fgs/etc/conf/httpd.conf and the local user environment I have
LD_LIBRARY_PATH set to /opt/fgs/lib:/opt/fgs/www/lib.

Is there a way to see the environment for the Apache user? I don't know how important this is. As mentioned everything else has been and is working very well.

Could there be some other conflicting system library picked up?

The URL I test with is
and I have confirmed all works fine when pointing the URL to other mapfiles.

I set the file and directory permissions to full access to all users temporarily to test and there is no difference in behavior.

When I run shp2img on the same mapfile the correct image is returned and there are no errors indicated in the ms_error file. The only oddity I see is in the path used by OGROpen:
 msLoadMap(): 0.033s
 msOGRFileWhichShapes: Setting spatial filter to -10515009.640986 3370567.000000 -9840476.359014 3918467.000000
 msOGRFileNextShape: Returning shape=0, tile=0
*** 62 shapes snipped here, there are 64 total polygons ***
 msOGRFileNextShape: Returning shape=63, tile=0
 msOGRFileNextShape: Returning MS_DONE (no more shapes)
 msDrawMap(): Layer 0 (parishes_on_boiladv), 0.118s
 msDrawMap(): Drawing Label Cache, 0.000s
 msDrawMap() total time: 0.126s
 msSaveImage() total time: 0.311s
 msFreeMap(): freeing map at 0x9d36ac8.
 freeLayer(): freeing layer at 0x9d3d7d8.
 shp2img total time: 0.472s

What else can I test?

If you made it this far, thanks for taking the time to read!

I am very grateful for any and all advice.
Johan Forsman
Safe Drinking Water Program
Louisiana Department of Health and Hospitals
Office of Public Health
Telephone: 225.342.7309
Telefax: 225.342.7303

-------------- next part --------------
A non-text attachment was scrubbed...
Name: image_by_shp2img.png
Type: image/png
Size: 24651 bytes
Desc: image_by_shp2img.png
Url : http://lists.osgeo.org/pipermail/mapserver-users/attachments/20100813/9b45d690/image_by_shp2img-0001.png

More information about the mapserver-users mailing list