[Mapserver-dev] 24-bit image processing crash

Brent Fraser bfraser at geoanalytic.com
Sat Jan 18 13:52:26 EST 2003


This is a multi-part message in MIME format.

------=_NextPart_000_012C_01C2BEE8.12067B60
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Frank,

  I've got a build of Mapserver on Win2k (nightly snapshot from =
2003/01/14, GD-2.0.10,with GDAL-1.1.8).  It crashes when I have a CLASS =
defined for a raster layer of a 24-bit tif:

LAYER
  NAME 'TopoMaps'
  GROUP "Raster Backdrops"=20
  TYPE raster
  STATUS on
  PROJECTION
    "proj=3Dutm"
    "ellps=3DWGS84"
    "zone=3D12"
     "north"
  END
  DATA 'C:\Inetpub\wwwroot\modis\site\basemap\072l12nc_83_24.tif'
#  DATA 'C:\Inetpub\wwwroot\modis\site\basemap\072l12nc_83.tif'
    CLASS
     NAME "1:50k Topomaps"
    END
END  # LAYER

But doesn't crash when the tif is 8-bit /paletted (then it renders all =
the pixels as blue, but that's a different problem).

In the debugger it shows it's caused by msDrawRasterLayerGDAL =
(mapdrawgdal.c around line 414) :
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
  /*
   * Setup the mapping between source eightbit pixel values, and the
   * output images color table.  There are two general cases, where the
   * class colors are provided by the MAP file, or where we use the =
native
   * color table.
   */
  if(layer->numclasses > 0 && gdImg ) {
    int c;

    cmap_set =3D TRUE;

    for(i=3D0; i<GDALGetColorEntryCount(hColorMap); i++) {
        GDALColorEntry sEntry;
        colorObj pixel;

        GDALGetColorEntryAsRGB( hColorMap, i, &sEntry );
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
It appears to crash since hColorMap is NULL and the called function =
attempts to access it's data members.

I'm not clear why msDrawRasterLayerGDAL is trying to do ColorMap =
processing on a 24-bit image.

Any thoughts?

Brent Fraser
GeoAnalytic Inc.
Tel:(403) 213-2700
bfraser at geoanalytic.com
www.geoanalytic.com

------=_NextPart_000_012C_01C2BEE8.12067B60
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Frank,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; I've got a build of Mapserver on =
Win2k=20
(nightly snapshot from 2003/01/14, GD-2.0.10,with GDAL-1.1.8).&nbsp; It =
crashes=20
when I have a CLASS defined for a raster layer of a 24-bit =
tif:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>LAYER<BR>&nbsp; NAME =
'TopoMaps'<BR>&nbsp; GROUP=20
"Raster Backdrops"&nbsp;<BR>&nbsp; TYPE raster<BR>&nbsp; STATUS =
on<BR>&nbsp;=20
PROJECTION<BR>&nbsp;&nbsp;&nbsp; "proj=3Dutm"<BR>&nbsp;&nbsp;&nbsp;=20
"ellps=3DWGS84"<BR>&nbsp;&nbsp;&nbsp; =
"zone=3D12"<BR>&nbsp;&nbsp;&nbsp;&nbsp;=20
"north"<BR>&nbsp; END<BR>&nbsp; DATA=20
'C:\Inetpub\wwwroot\modis\site\basemap\072l12nc_83_24.tif'<BR>#&nbsp; =
DATA=20
'C:\Inetpub\wwwroot\modis\site\basemap\072l12nc_83.tif'<BR>&nbsp;&nbsp;&n=
bsp;=20
CLASS<BR>&nbsp;&nbsp;&nbsp; &nbsp;NAME "1:50k =
Topomaps"<BR>&nbsp;&nbsp;&nbsp;=20
END<BR>END&nbsp; # LAYER</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>But doesn't crash when the tif is 8-bit =
/paletted=20
(then it renders all the pixels as blue, but that's a different=20
problem).</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>In the debugger it shows =
it's&nbsp;caused=20
by&nbsp;msDrawRasterLayerGDAL (mapdrawgdal.c around line=20
414)&nbsp;:</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FO=
NT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; /*<BR>&nbsp;&nbsp; * Setup the =
mapping=20
between source eightbit pixel values, and the<BR>&nbsp;&nbsp; * output =
images=20
color table.&nbsp; There are two general cases, where =
the<BR>&nbsp;&nbsp; *=20
class colors are provided by the MAP file, or where we use the=20
native<BR>&nbsp;&nbsp; * color table.<BR>&nbsp;&nbsp; */<BR>&nbsp;=20
if(layer-&gt;numclasses &gt; 0 &amp;&amp; gdImg ) =
{<BR>&nbsp;&nbsp;&nbsp; int=20
c;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; cmap_set =3D =
TRUE;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; for(i=3D0;=20
i&lt;GDALGetColorEntryCount(<STRONG>hColorMap</STRONG>); i++)=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GDALColorEntry=20
sEntry;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; colorObj=20
pixel;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
GDALGetColorEntryAsRGB( hColorMap, i, &amp;sEntry );</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<=
/FONT></DIV>
<DIV><FONT face=3DArial size=3D2>It appears to crash since hColorMap is =
NULL and the=20
called function attempts to access it's data members.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I'm not clear why msDrawRasterLayerGDAL =
is trying=20
to do ColorMap processing on a 24-bit image.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Any thoughts?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Brent Fraser</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>GeoAnalytic Inc.<BR>Tel:(403) =
213-2700<BR><A=20
href=3D"mailto:bfraser at geoanalytic.com">bfraser at geoanalytic.com</A><BR><A=
=20
href=3D"http://www.geoanalytic.com">www.geoanalytic.com</A></FONT></DIV><=
/BODY></HTML>

------=_NextPart_000_012C_01C2BEE8.12067B60--




More information about the mapserver-dev mailing list