Opened 15 years ago

Closed 15 years ago

#2929 closed defect (fixed)

clean up GEOS init and cleanup functions

Reported by: tomkralidis Owned by: tomkralidis
Priority: normal Milestone: 5.4 release
Component: MapServer C Library Version: svn-trunk (development)
Severity: normal Keywords:
Cc: assefa, pramsey, nsavard, dmorissette

Description

When testing WFS filters with GEOS:

[devgeo:/home/tkralidi/foss4g/mapserver/trunk/msautotest/wxs]$ gdb  --args ../../mapserver/mapserv QUERY_STRING="map=./wfs_filter.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=province&FILTER=<Filter><Intersect><PropertyName>Geometry</PropertyName><gml:LineString><gml:coordinates>-62.94,46.61 -62.74,45.83</gml:coordinates></gml:LineString></Intersect></Filter>"

MapServer crashes with the following:

*** glibc detected *** /home/tkralidi/foss4g/mapserver/trunk/mapserver/mapserv: double free or corruption (!prev): 0x081c0fe8 ***
[New Thread 0xb7fdd770 (LWP 9644)]
======= Backtrace: =========
/lib/libc.so.6[0x1e453a4]
/lib/libc.so.6(cfree+0x96)[0x1e47356]
/usr/local/lib/libgeos_c.so.1(finishGEOS_r+0x21)[0x43aaf1]
/usr/local/lib/libgeos_c.so.1(finishGEOS+0x22)[0x4358a2]
/home/tkralidi/foss4g/mapserver/trunk/mapserver/mapserv(msGEOSCleanup+0x17)[0x812e4b7]
/home/tkralidi/foss4g/mapserver/trunk/mapserver/mapserv(msCleanup+0x5d)[0x808bf6d]
/home/tkralidi/foss4g/mapserver/trunk/mapserver/mapserv(main+0xa32)[0x80677b2]
/lib/libc.so.6(__libc_start_main+0xe5)[0x1dec6e5]
/home/tkralidi/foss4g/mapserver/trunk/mapserver/mapserv[0x8063d21]
======= Memory map: ========
00101000-0010e000 r-xp 00000000 68:03 10977499   /lib/libgcc_s-4.3.2-20081105.so.1
0010e000-0010f000 rw-p 0000c000 68:03 10977499   /lib/libgcc_s-4.3.2-20081105.so.1
00111000-00121000 r-xp 00000000 68:11 4194341    /usr/lib/libXpm.so.4.11.0
00121000-00122000 rw-p 0000f000 68:11 4194341    /usr/lib/libXpm.so.4.11.0
00122000-00155000 r-xp 00000000 68:11 4194420    /usr/lib/libagg.so.2.0.4
00155000-00158000 rw-p 00032000 68:11 4194420    /usr/lib/libagg.so.2.0.4
00158000-00270000 r-xp 00000000 68:11 20250998   /usr/local/lib/libpdf.so.6.0.0
00270000-00297000 rw-p 00118000 68:11 20250998   /usr/local/lib/libpdf.so.6.0.0
00297000-002ad000 r-xp 00000000 68:03 10977559   /lib/libnsl-2.9.so
002ad000-002ae000 r--p 00016000 68:03 10977559   /lib/libnsl-2.9.so
002ae000-002af000 rw-p 00017000 68:03 10977559   /lib/libnsl-2.9.so
002af000-002b1000 rw-p 002af000 00:00 0 
002b1000-002b8000 r-xp 00000000 68:11 4194684    /usr/lib/libSM.so.6.0.0
002b8000-002b9000 rw-p 00006000 68:11 4194684    /usr/lib/libSM.so.6.0.0
002b9000-002bb000 r-xp 00000000 68:03 10977384   /lib/libcom_err.so.2.1
002bb000-002bc000 rw-p 00001000 68:03 10977384   /lib/libcom_err.so.2.1
002bc000-00325000 r-xp 00000000 68:11 4194951    /usr/lib/libsqlite3.so.0.8.6
00325000-00327000 rw-p 00068000 68:11 4194951    /usr/lib/libsqlite3.so.0.8.6
00327000-00373000 r-xp 00000000 68:11 4194842    /usr/lib/libcurl.so.4.1.1
00373000-00375000 rw-p 0004b000 68:11 4194842    /usr/lib/libcurl.so.4.1.1
00375000-0039c000 r-xp 00000000 68:03 10977373   /lib/libm-2.9.so
0039c000-0039d000 r--p 00026000 68:03 10977373   /lib/libm-2.9.so
0039d000-0039e000 rw-p 00027000 68:03 10977373   /lib/libm-2.9.so
0039e000-003e5000 r-xp 00000000 68:03 10977316   /lib/libssl.so.0.9.8g
003e5000-003e9000 rw-p 00046000 68:03 10977316   /lib/libssl.so.0.9.8g
003e9000-0042a000 r-xp 00000000 68:11 20250716   /usr/local/lib/libming.so.0.3.0beta2
0042a000-0042c000 rw-p 00041000 68:11 20250716   /usr/local/lib/libming.so.0.3.0beta2
0042c000-0042e000 rw-p 0042c000 00:00 0 
0042e000-00441000 r-xp 00000000 68:11 20250696   /usr/local/lib/libgeos_c.so.1.5.0
00441000-00442000 rw-p 00012000 68:11 20250696   /usr/local/lib/libgeos_c.so.1.5.0
00442000-00470000 r-xp 00000000 68:11 4195156    /usr/lib/libfontconfig.so.1.3.0
00470000-00471000 rw-p 0002e000 68:11 4195156    /usr/lib/libfontconfig.so.1.3.0
00471000-00488000 r-xp 00000000 68:11 4195079    /usr/lib/libICE.so.6.3.0
00488000-00489000 rw-p 00016000 68:11 4195079    /usr/lib/libICE.so.6.3.0
00489000-0048b000 rw-p 00489000 00:00 0 
0048b000-0048e000 r-xp 00000000 68:03 10977335   /lib/libplds4.so
0048e
Program received signal SIGABRT, Aborted.
0x004a2416 in __kernel_vsyscall ()
Missing separate debuginfos, use: debuginfo-install agg-2.5-6.fc9.i386 cyrus-sasl-lib-2.1.22-19.fc10.i386 e2fsprogs-libs-1.41.4-1.fc10.i386 expat-2.0.1-5.i386 fontconfig-2.6.0-3.fc10.i386 gd-2.0.35-6.fc10.i386 glibc-2.9-3.i686 keyutils-libs-1.2-3.fc9.i386 krb5-libs-1.6.3-16.fc10.i386 libICE-1.0.4-4.fc10.i386 libSM-1.1.0-2.fc10.i386 libX11-1.1.4-6.fc10.i386 libXau-1.0.4-1.fc10.i386 libXdmcp-1.0.2-6.fc10.i386 libXpm-3.5.7-4.fc9.i386 libcurl-7.19.4-1.fc10.i386 libgcc-4.3.2-7.i386 libidn-0.6.14-8.i386 libjpeg-6b-43.fc10.i386 libpng-1.2.35-1.fc10.i386 libselinux-2.0.73-1.fc10.i386 libssh2-0.18-7.fc9.i386 libstdc++-4.3.2-7.i386 libxcb-1.1.91-5.fc10.i386 libxml2-2.7.3-1.fc10.i386 mysql-libs-5.0.67-2.fc10.i386 nspr-4.7.3-2.fc10.i386 nss-3.12.2.0-4.fc10.i386 openldap-2.4.12-1.fc10.i386 openssl-0.9.8g-12.fc10.i686 postgresql-libs-8.3.6-1.fc10.i386 sqlite-3.5.9-4.fc10.i386 xerces-c-2.8.0-2.fc10.i386 zlib-1.2.3-18.fc9.i386
(gdb) bt
#0  0x004a2416 in __kernel_vsyscall ()
#1  0x01e01460 in raise () from /lib/libc.so.6
#2  0x01e02e28 in abort () from /lib/libc.so.6
#3  0x01e3efed in __libc_message () from /lib/libc.so.6
#4  0x01e453a4 in malloc_printerr () from /lib/libc.so.6
#5  0x01e47356 in free () from /lib/libc.so.6
#6  0x0043aaf1 in finishGEOS_r (extHandle=0x0) at geos_ts_c.cpp:151
#7  0x004358a2 in finishGEOS () at geos_c.cpp:85
#8  0x0812e4b7 in msGEOSCleanup () at mapgeos.c:65
#9  0x0808bf6d in msCleanup () at maputil.c:1700
#10 0x080677b2 in main (argc=2, argv=0xbffff534) at mapserv.c:1817
(gdb) 


Further investigation shows that the various setup and cleanup calls can create the behaviour above.

The attached patch by Assefa and I attempts to fix this issue.

Assefa: as discussed, can you check if this is okay for MapScript?

Attachments (1)

ms-trac-2929.patch (2.7 KB ) - added by tomkralidis 15 years ago.

Download all attachments as: .zip

Change History (17)

by tomkralidis, 15 years ago

Attachment: ms-trac-2929.patch added

comment:1 by tomkralidis, 15 years ago

Cc: assefa added

comment:2 by tomkralidis, 15 years ago

Cc: pramsey nsavard added
Summary: fix usage of msSetupclean up GEOS init and cleanup functions

Committed in trunk in r8713.

Here are two test cases against the patch which return a buffered shape (produced by GEOS) as expected:

<?php
dl("php_mapscript.so");

$shape = ms_shapeObjFromWkt('POINT(6 10)');

echo $shape->buffer(10)->toWkt();

?>
#!/usr/bin/python

import mapscript

print mapscript.shapeObj(mapscript.MS_SHAPE_POINT).fromWKT('POINT(6 10)').buffer(10).toWKT()

Norm: can you double check msautotest/wxs/wfs_filter.map when you have a chance?

comment:3 by tomkralidis, 15 years ago

Owner: changed from sdlime to tomkralidis
Status: newassigned

comment:4 by tomkralidis, 15 years ago

Here's an accompanying test in Perl:

#!/usr/bin/perl

use strict;
use warnings;
use mapscript;

my $s = mapscript::shapeObj::fromWKT('POINT (6 10)');

print $s->buffer(10)->toWKT();

comment:5 by nsavard, 15 years ago

Re comment:2

I'll test on my linux box.

comment:6 by nsavard, 15 years ago

Re comment:2

Tom, I have four failures right now with the MapServer trunk version on Ubuntu:

wfs_filter_crosses.xml wfs_filter_isequalto_and_isequalto_reverse.xml wfs_filter_equals_poly.xml wfs_filter_isequalto_and_isequalto.xml

in reply to:  6 comment:7 by tomkralidis, 15 years ago

Replying to nsavard:

Re comment:2

Tom, I have four failures right now with the MapServer trunk version on Ubuntu:

wfs_filter_crosses.xml wfs_filter_isequalto_and_isequalto_reverse.xml wfs_filter_equals_poly.xml wfs_filter_isequalto_and_isequalto.xml

Norm: same thing for me. I believe these were there prior to the changes in this ticket.

comment:8 by nsavard, 15 years ago

Tom:

I was asked by Yewondwossen to test the wfs_filter.map last Friday and I recorded only one failure. Here is a snippet of the email I sent to him.

Email 06/03/09 04:12 PM:

I just ran it and all tests passed with 5.4.0-beta3 except this one where there is already ticket 2308 for:

test wfs_filter_equals_poly.xml

sh: perceptualdiff: not found

  • results dont match, TEST FAILED.

in reply to:  8 comment:9 by tomkralidis, 15 years ago

Replying to nsavard:

Tom:

I was asked by Yewondwossen to test the wfs_filter.map last Friday and I recorded only one failure. Here is a snippet of the email I sent to him.

Email 06/03/09 04:12 PM:

I just ran it and all tests passed with 5.4.0-beta3 except this one where there is already ticket 2308 for:

test wfs_filter_equals_poly.xml

sh: perceptualdiff: not found

  • results dont match, TEST FAILED.

Norm: thanks. Small fix made. Now I get only one failing test per #2308. Can you verify?

comment:10 by nsavard, 15 years ago

Tom: I'll do that this morning and let you know.

comment:11 by nsavard, 15 years ago

Re comment:9

Tom this is fixed. Only one test failed. Thanks.

comment:12 by tomkralidis, 15 years ago

Resolution: fixed
Status: assignedclosed

comment:13 by sdlime, 15 years ago

What do folks think about backporting to 5.4 before it's released? Change seems benign enough so I'd be a +1.

Steve

comment:14 by dmorissette, 15 years ago

Cc: dmorissette added

+1. Daniel

comment:15 by sdlime, 15 years ago

Milestone: 6.0 release5.4 release
Resolution: fixed
Status: closedreopened

comment:16 by tomkralidis, 15 years ago

Resolution: fixed
Status: reopenedclosed

committed to branch-5-4 in r8872. Test per comment:4 and msautotest/wxs/wfs_filter.map with success.

Note: See TracTickets for help on using tickets.