<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<div class="moz-text-flowed"
 style="font-family: -moz-fixed; font-size: 12px;" lang="x-western">Hi,
<br>
I had some problems with legend mode when I was worked with fastCGI
some months ago. I had to stop this job for a time, but I can retake it
again now.
<br>
I'm testing the last CGI MapServer version. When i want use the legend
template option MapServer crashes in some cases (and isn't fastCGI).
<br>
I atach a test case to reproduce (mapfile, legend template and url)
this problem.
<br>
<br>
The MapServer version:
<br>
<br>
/usr/local/apache/cgi-bin/mapserv -v
<br>
MapServer version 4.10.0-rc1 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG
OUTPUT=WBMP OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE
SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER
SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER INPUT=EPPL7 INPUT=POSTGIS
INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
<br>
<br>
Valgrind results:
<br>
<br>
valgrind /usr/local/apache/cgi-bin/mapserv
QUERY_STRING='map=/usr/local/apache/htdocs/mapserver/maps/prueba.map&amp;mode=legend&amp;layers=a+b&amp;mapext=458350+4613016+704030+4858696&amp;mapsize=350+350&amp;map_legend_template=../templates/legend_pruebas.html'
<br>
==3299== Memcheck, a memory error detector for x86-linux.
<br>
==3299== Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward.
<br>
==3299== Using valgrind-2.1.0, a program supervision framework for
x86-linux.
<br>
==3299== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward.
<br>
==3299== Estimated CPU clock rate is 1922 MHz
<br>
==3299== For more details, rerun with: -v
<br>
==3299==
<br>
==3299== Invalid free() / delete / delete[]
<br>
==3299==&nbsp;&nbsp;&nbsp; at 0x4002B455: free (vg_replace_malloc.c:186)
<br>
==3299==&nbsp;&nbsp;&nbsp; by 0x40BBBCBB: (within /lib/i686/libc-2.3.3.so)
<br>
==3299==&nbsp;&nbsp;&nbsp; by 0x40BBB951: __libc_freeres (in /lib/i686/libc-2.3.3.so)
<br>
==3299==&nbsp;&nbsp;&nbsp; by 0x4016AACC: vgPlain___libc_freeres_wrapper
(vg_intercept.c:172)
<br>
==3299==&nbsp; Address 0x410AA570 is not stack'd, malloc'd or free'd
<br>
==3299==
<br>
==3299== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
<br>
==3299== malloc/free: in use at exit: 19708 bytes in 16 blocks.
<br>
==3299== malloc/free: 1746 allocs, 1731 frees, 1759492 bytes allocated.
<br>
==3299== For a detailed leak analysis,&nbsp; rerun with: --leak-check=yes
<br>
==3299== For counts of detected errors, rerun with: -v
<br>
<br>
Thanks,
<br>
&nbsp;&nbsp; Miguel
<br>
<br>
Mguel Coladas escribi&oacute;:
<br>
<blockquote type="cite">I have tried using valgrind --num-callers=20,
but don't tell much anyway.
  <br>
  <br>
I'm testing if the crash is caused by a special layer, or by a special
set of layers.
  <br>
It seems that when I put more than seven layers visibles in the legend
mapserver crash. If i put maxscale and minscale works, but the layers
are not visible.
  <br>
  <br>
When i can, i&nbsp; package a test case to send you.
  <br>
  <br>
Thanks
  <br>
  <br>
Daniel Morissette escribi&oacute;:
  <br>
  <blockquote type="cite">Um.. it seems that Valgrind is finding
something but we can't tell much from this Valgrind output. Perhaps try
using 'valgrind --num-callers=20' to get a more complete call stack in
the Valgrind output (note that since the error is reported inside
valgrind's libc_freeres_wrapper that probably won't tell us much
anyway, but we can try).
    <br>
    <br>
Would it be possible for you to package a test case (mapfile, data,
html templates, etc.) to send us to reproduce this issue? Since this is
happening when generating in mode=legend, we may be able get away with
a test case with just the mapfile and templates (without the data) but
I'm not sure.
    <br>
    <br>
Daniel
    <br>
    <br>
    <br>
miguel coladas wrote:
    <br>
    <blockquote type="cite">Thanks for your answer Daniel.
      <br>
      <br>
I'm testing with latest 4.10 beta and I'm having some problems
      <br>
      <br>
[miguel@mcoladas miguel]$ /usr/local/apache/fcgi-bin/mapserv -v
      <br>
MapServer version 4.10.0-beta1 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG
OUTPUT=WBMP OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE
SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER
SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=FASTCGI INPUT=EPPL7
INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
      <br>
      <br>
With this version of mapserver I have run Valgrind at the command line
as you tell me:
      <br>
      <br>
[miguel@mcoladas miguel]$ valgrind
/usr/local/apache/fcgi-bin/mapserv
QUERY_STRING="map=/usr/local/apache/htdocs/mapserver/map/client-draw.map&amp;mode=legend&amp;layers=provincias&amp;mapext=458350+4613016+704030+4858696&amp;mapsize=350+350&amp;map_legend_template=../templates/legend.html"
      <br>
==5322== Memcheck, a memory error detector for x86-linux.
      <br>
==5322== Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward.
      <br>
==5322== Using valgrind-2.1.0, a program supervision framework for
x86-linux.
      <br>
==5322== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward.
      <br>
==5322== Estimated CPU clock rate is 1923 MHz
      <br>
==5322== For more details, rerun with: -v
      <br>
==5322==
      <br>
==5322== Invalid free() / delete / delete[]
      <br>
==5322==&nbsp;&nbsp;&nbsp; at 0x4002B455: free (vg_replace_malloc.c:186)
      <br>
==5322==&nbsp;&nbsp;&nbsp; by 0x40BC4CBB: (within /lib/i686/libc-2.3.3.so)
      <br>
==5322==&nbsp;&nbsp;&nbsp; by 0x40BC4951: __libc_freeres (in /lib/i686/libc-2.3.3.so)
      <br>
==5322==&nbsp;&nbsp;&nbsp; by 0x4016AACC: vgPlain___libc_freeres_wrapper
(vg_intercept.c:172)
      <br>
==5322==&nbsp; Address 0x410897F8 is not stack'd, malloc'd or free'd
      <br>
==5322==
      <br>
==5322== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
      <br>
==5322== malloc/free: in use at exit: 58517 bytes in 129 blocks.
      <br>
==5322== malloc/free: 14327 allocs, 14199 frees, 4390277 bytes
allocated.
      <br>
==5322== For a detailed leak analysis,&nbsp; rerun with: --leak-check=yes
      <br>
==5322== For counts of detected errors, rerun with: -v
      <br>
      <br>
any idea?
      <br>
      <br>
      <br>
Daniel Morissette escribi&oacute;:
      <br>
      <br>
      <blockquote type="cite">If you are on Linux then you could
perhaps capture the URL of the request that causes the crash, and then
run it under Valgrind (<a class="moz-txt-link-freetext"
 href="http://valgrind.org/">http://valgrind.org/</a>) at the command
line using something like:
        <br>
        <br>
valgrind ./mapserv QUERY_STRING="map=....."
        <br>
        <br>
You get the value of QUERY_STRING from the URL that causes the crash.
        <br>
        <br>
If Valgrind reports errors then I suggest you create a bug report with
the Valgrind output and a test case to reproduce (including mapfile,
test dataset, etc. and the query_string that causes the crash).
        <br>
        <br>
BTW, I would suggest that you test this against the latest 4.10 beta
before reporting a bug.
        <br>
        <br>
Daniel
        <br>
        <br>
        <br>
        <br>
miguel coladas wrote:
        <br>
        <br>
        <blockquote type="cite">Hi everyone,
          <br>
          <br>
first i'm spanish, so sorry for my english.
          <br>
I'm using mapserver (4.8.3) in fast CGI mode (apache 2.0.59,
mod_fastcgi/2.4.2). I'm having some problems with this configuration
when i want use the legend template option.
          <br>
In the legend template file, when I put "[leg_layer_html opt_flag=1]"
the legend works correctly. However, when I put "[leg_layer_html
opt_flag=2]" mapserver crashes. In CGI mode, the same legend works
correctly. Other modes (map, query... works correctly too).
          <br>
          <br>
The error_log of apache server:
          <br>
          <br>
[Mon Aug 21 18:16:43 2006] [error] [client 192.168.1.3] Premature end
of script headers: mapserv
          <br>
          <br>
I think this is a bug with mapserver in fast CGI mode. Can anyone help
me out with this?
          <br>
          <br>
Many thanks,
          <br>
          <br>
&nbsp;&nbsp;&nbsp; Miguel Coladas
          <br>
        </blockquote>
        <br>
        <br>
        <br>
      </blockquote>
      <br>
    </blockquote>
    <br>
    <br>
  </blockquote>
  <br>
</blockquote>
</div>
</body>
</html>