<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} p
        {margin-top:0;
        margin-bottom:0}--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi,</p>
<p><br>
</p>
<p>Agreed, it shouldn't segfault, but I do not quite understand how these empty geometries ever get selected.  It is PostGIS backend and WMS GetMap request. As far as I know Mapserver in this case adds the "&&" or "bounding boxes intersect" query to the main query
 by using the layer extent as reference. As far as I know the only way to prevent this is to set metadata item "wfs_use_default_extent_for_getfeature" to false as documented in
<a href="http://mapserver.org/ogc/wfs_server.html">http://mapserver.org/ogc/wfs_server.html</a> and even then this only affects WFS service.</p>
<p><br>
</p>
<p>I made a test with PostGIS by interting two geometries into a table:</p>
<p>POLYGON (( 40 40, 40 120, 120 120, 120 40, 40 40 ))</p>
<p>LINESTRING EMPTY</p>
<p><br>
</p>
<p>Query </p>
<p>select * from bbox_test<br>
where "GEOMETRY" && ST_GeomFromText('POLYGON (( 40 40, 40 120, 120 120, 120 40, 40 40 ))');</p>
<p>does not return the empty geometry.</p>
<p><br>
</p>
<p>I believe that Dave has something not typical in his environment. As he said, OSM data tend to have empty geometries but for most users rendering OS data still works. What have given problems for me are not empty geometries but invalid ones, typically polygons
 with only three vertices A-B-A.<br>
</p>
<p><br>
</p>
<p>Dave, please add DEBUG 5 into your layer. It should then log the exact SQL that Mapserver is generating. Check if the && part is added into the query and if it is run the same query diretly with pgAdmin and see if the empty geometries are really selected.</p>
<p><br>
</p>
<p>-Jukka Rahkonen-<br>
</p>
<p><br>
</p>
<div style="color:rgb(33,33,33)">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>Lähettäjä:</b> mapserver-users <mapserver-users-bounces@lists.osgeo.org> käyttäjän puolestaLime, Steve D (MNIT) <steve.lime@state.mn.us><br>
<b>Lähetetty:</b> 18. elokuuta 2017 23:45<br>
<b>Vastaanottaja:</b> Andrea Peri<br>
<b>Kopio:</b> Dave Barter; mapserver-users@lists.osgeo.org<br>
<b>Aihe:</b> Re: [mapserver-users] Segfault - LINE layer</font>
<div> </div>
</div>
<div>agreed, shouldn't segfault in either case
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Andrea Peri <aperi2007@gmail.com><br>
<b>Sent:</b> Friday, August 18, 2017 2:22:15 PM<br>
<b>To:</b> Lime, Steve D (MNIT)<br>
<b>Cc:</b> Dave Barter; mapserver-users@lists.osgeo.org<br>
<b>Subject:</b> Re: [mapserver-users] Segfault - LINE layer</font>
<div> </div>
</div>
<div>
<div dir="auto">Hi, I guess the avoid of empty or null geometries should happened surely in wms service.
<div dir="auto">Not sure It is good in wfs services.</div>
<div dir="auto"><br>
</div>
<div dir="auto">A.</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">Il 18 Ago 2017 17:19, "Lime, Steve D (MNIT)" <<a href="mailto:steve.lime@state.mn.us">steve.lime@state.mn.us</a>> ha scritto:<br type="attribution">
<blockquote class="quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-US">
<div class="m_2769304143874504484WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1f497d">Still it the code should gracefully skip empty geometries. Can you create a ticket please?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1f497d"><u></u> <u></u></span></p>
<div>
<div style="border:none; border-top:solid #e1e1e1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"> mapserver-users [mailto:<a href="mailto:mapserver-users-bounces@lists.osgeo.org" target="_blank">mapserver-users-<wbr>bounces@lists.osgeo.org</a>]
<b>On Behalf Of </b>Dave Barter<br>
<b>Sent:</b> Friday, August 18, 2017 9:56 AM<br>
<b>To:</b> <a href="mailto:mapserver-users@lists.osgeo.org" target="_blank">mapserver-users@lists.osgeo.<wbr>org</a><br>
<b>Subject:</b> Re: [mapserver-users] Segfault - LINE layer<u></u><u></u></span></p>
</div>
</div>
<div class="elided-text">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<blockquote style="margin-top:5.0pt; margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1f497d"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1f497d">As a quick workaround edit your DATA:</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1f497d"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">where type in ('trunk','motorway','primary') AND geometry is not null</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">-Jukka Rahkonen-</span><u></u><u></u></p>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">That will not work as an empty geometry is not null<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">The fix is WHERE NOT ST_EMPTY(geometry)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><br>
<br>
<u></u><u></u></p>
<blockquote style="margin-top:5.0pt; margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1f497d"> </span><u></u><u></u></p>
</div>
<div>
<div style="border:none; border-top:solid #e1e1e1 1.0pt; padding:3.0pt 0in 0in 0in">
<div>
<p class="MsoNormal"><b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">Lähettäjä:</span></b><span class="m_2769304143874504484apple-converted-space"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"> </span></span><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">mapserver-users
 [<a href="mailto:mapserver-users-bounces@lists.osgeo.org" target="_blank"><span style="color:purple">mailto:mapserver-users-<wbr>bounces@lists.osgeo.org</span></a>]<span class="m_2769304143874504484apple-converted-space"> </span><b>Puole<wbr>sta<span class="m_2769304143874504484apple-converted-space"> </span></b>Dave
 Barter<br>
<b>Lähetetty:</b><span class="m_2769304143874504484apple-converted-space"> </span>18. elokuuta 2017 16:05<br>
<b>Vastaanottaja:</b><span class="m_2769304143874504484apple-converted-space"> </span><a href="mailto:mapserver-users@lists.osgeo.org" target="_blank"><span style="color:purple">mapserver-<wbr>users@lists.osgeo.org</span></a><br>
<b>Aihe:</b><span class="m_2769304143874504484apple-converted-space"> </span>Re: [mapserver-users] Segfault - LINE layer</span><u></u><u></u></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<blockquote style="margin-top:5.0pt; margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal">On 18 Aug 2017, at 13:44, Lime, Steve D (MNIT) <<a href="mailto:steve.lime@state.mn.us" target="_blank"><span style="color:purple">steve.lime@state.mn.us</span></a>> wrote:<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt; font-family:"Helvetica",sans-serif">I'd call it a bug. What version? Can you prepare a small test case?<span class="m_2769304143874504484apple-converted-space"> </span></span><u></u><u></u></p>
</div>
</div>
</div>
</blockquote>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">MapServer version 7.0.4 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=<wbr>CAIRO SUPPORTS=SVG_SYMBOLS SUPPORTS=RSVG SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=<wbr>WMS_CLIENT SUPPORTS=WFS_SERVER
 SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=<wbr>FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE<u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">I have tracked it down to a specific geometry:-<u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">010200000000000000 = ‘LINESTRING EMPTY’<u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<blockquote style="margin-top:5.0pt; margin-bottom:5.0pt">
<div>
<div>
<div class="MsoNormal" style="text-align:center" align="center"><span style="font-size:9.0pt; font-family:"Helvetica",sans-serif">
<hr style="width:510.1pt" size="3" width="680" align="center">
</span></div>
<div id="m_2769304143874504484x_divRplyFwdMsg">
<div>
<p class="MsoNormal"><b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">From:</span></b><span class="m_2769304143874504484apple-converted-space"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"> </span></span><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">mapserver-users
 <<a href="mailto:mapserver-users-bounces@lists.osgeo.org" target="_blank"><span style="color:purple">mapserver-users-bounces@<wbr>lists.osgeo.org</span></a>> on behalf of Dave Barter <<a href="mailto:dave@phased.co.uk" target="_blank"><span style="color:purple">dave@phased.co.uk</span></a>><br>
<b>Sent:</b><span class="m_2769304143874504484apple-converted-space"> </span>Friday, August 18, 2017 5:13:29 AM<br>
<b>To:</b><span class="m_2769304143874504484apple-converted-space"> </span><a href="mailto:mapserver-users@lists.osgeo.org" target="_blank"><span style="color:purple">mapserver-users@lists.<wbr>osgeo.org</span></a><br>
<b>Subject:</b><span class="m_2769304143874504484apple-converted-space"> </span>[mapserver-users] Segfault - LINE layer</span><u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt; font-family:"Helvetica",sans-serif"> </span><u></u><u></u></p>
</div>
</div>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Helvetica",sans-serif">This call:-<br>
<br>
/usr/lib/cgi-bin/mapserv.ngx -nh "QUERY_STRING=map=/usr/src/<wbr>app/mapfiles/api/wms_osm_<wbr>google_world_bw.map&SERVICE=<wbr>WMS&VERSION=1.1.1&REQUEST=<wbr>GetMap&SERVICE=WMS&STYLES=&<wbr>BBOX=-6114.962263%2c6099063.<wbr>360931%2c162657.996191%<wbr>2c6267836.319384&WIDTH=276&<wbr>HEIGHT=276&FORMAT=image%2fpng&<wbr>SRS=EPSG%3a3857&LAYERS=roads8&<wbr>transparent=false<br>
<br>
Is giving me:-<br>
<br>
Segmentation fault (core dumped)<br>
<br>
For the layer definition:-<br>
<br>
LAYER<br>
    GROUP "default"<br>
    STATUS ON<br>
    TYPE LINE<br>
    MINSCALEDENOM 1300032<br>
    MAXSCALEDENOM 2600064<br>
    NAME "roads8"<br>
    DEBUG 5<br>
    CONNECTIONTYPE postgis<br>
    PROCESSING "CLOSE_CONNECTION=DEFER"<br>
    {%public_map_user%}<br>
    PROJECTION<br>
        "init=epsg:900913"<br>
    END<br>
    DATA "geometry from (select osm_id,geometry,name as name,ref,type from mapping_osm.osm_new_roads_gen1 where type in ('trunk','motorway','primary') order by z_order asc) as foo using unique osm_id using srid=900913"<br>
    LABELITEM "name"<br>
    CLASSITEM "type"<br>
    CLASS<br>
        EXPRESSION {primary,primary_link}<br>
        STYLE<br>
            WIDTH 0.5<br>
            COLOR 242 242 242<br>
        END<br>
    END<br>
    CLASS<br>
        EXPRESSION "motorway"<br>
        TEXT ("[ref]")<br>
        STYLE<br>
           WIDTH 1<br>
           OUTLINEWIDTH 0.5<br>
           OUTLINECOLOR 217 217 217<br>
        END<br>
        STYLE<br>
            WIDTH 1<br>
            COLOR 242 242 242<br>
<br>
        END<br>
    END<br>
    CLASS<br>
        EXPRESSION "trunk"<br>
        TEXT ("[ref]")<br>
        STYLE<br>
           WIDTH 1<br>
           OUTLINEWIDTH 0.5<br>
           OUTLINECOLOR 217 217 217<br>
        END<br>
        STYLE<br>
            WIDTH 1<br>
             COLOR 242 242 242<br>
        END<br>
    END<br>
END<br>
<br>
When I look in my debug file I see the following as last set of lines:-<br>
<br>
[Fri Aug 18 11:09:39 2017].945225 msPostGISReadShape: PQgetlength = 7<br>
[Fri Aug 18 11:09:39 2017].945236 msPostGISReadShape: [type] "primary"<br>
[Fri Aug 18 11:09:39 2017].945248 msPostGISReadShape: PQgetlength = 0<br>
[Fri Aug 18 11:09:39 2017].945259 msPostGISReadShape: [name] ""<br>
[Fri Aug 18 11:09:39 2017].945270 msPostGISReadShape: PQgetlength = 0<br>
[Fri Aug 18 11:09:39 2017].945281 msPostGISReadShape: [ref] ""<br>
[Fri Aug 18 11:09:39 2017].945292 msPostGISReadShape: Setting shape->index = 307691570<br>
[Fri Aug 18 11:09:39 2017].945303 msPostGISReadShape: Setting shape->resultindex = 327<br>
[Fri Aug 18 11:09:39 2017].945314 msPostGISReadShape: [index] 307691570<br>
[Fri Aug 18 11:09:39 2017].945346 msPostGISReadShape: [shape] LINESTRING (139231.1053743003285490 6233477.4797634640708566, 139274.7760105324559845 6233447.9814142314717174)<br>
[Fri Aug 18 11:09:39 2017].945369 msPostGISLayerNextShape called.<br>
[Fri Aug 18 11:09:39 2017].945383 msPostGISReadShape called.<br>
[Fri Aug 18 11:09:39 2017].94<br>
<br>
So it seems to segfault during  msPostGISReadShape.<span class="m_2769304143874504484apple-converted-space"> </span><br>
<br>
I’ve checked the query and it is pulling 3110 linestrings from the database.<span class="m_2769304143874504484apple-converted-space"> </span><br>
<br>
But I am not sure why is is segfaulting? Is this a bug?<br>
<br>
Dave Barter<br>
<a href="mailto:dave@phased.co.uk" target="_blank"><span style="color:purple">dave@phased.co.uk</span></a><br>
@citizenfishy<br>
<a href="http://www.phased.co.uk/" target="_blank"><span style="color:purple">www.phased.co.uk</span></a><br>
<br>
______________________________<wbr>_________________<br>
mapserver-users mailing list<br>
<a href="mailto:mapserver-users@lists.osgeo.org" target="_blank"><span style="color:purple">mapserver-users@lists.osgeo.<wbr>org</span></a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users" target="_blank"><span style="color:purple">https://lists.osgeo.org/<wbr>mailman/listinfo/mapserver-<wbr>users</span></a></span><u></u><u></u></p>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
<br>
______________________________<wbr>_________________<br>
mapserver-users mailing list<br>
<a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.<wbr>org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/mapserver-<wbr>users</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>