<div dir="ltr">Reposting this here as mapserver-users seems pretty dead...<br><br><div>I think I've discovered two causes of crashes...<br></div><br>First, one with the KML driver...<br><div><br>msDrawQueryLayer creates and draws a temporary layer here:<br><a href="https://github.com/mapserver/mapserver/blob/bdd421c7e69e2ff16841c12c08ba688b62a9f9a6/mapdraw.c#L1209" target="_blank">https://github.com/mapserver/mapserver/blob/bdd421c7e69e2ff16841c12c08ba688b62a9f9a6/mapdraw.c#L1209</a><br>The KML renderer sets a reference to the temporary layer here:<br><a href="https://github.com/mapserver/mapserver/blob/3e8aa5a4d92c9bad105306ebe5117ed29d2b0e7c/mapkmlrenderer.cpp#L371" target="_blank">https://github.com/mapserver/mapserver/blob/bdd421c7e69e2ff16841c12c08ba688b62a9f9a6/mapkmlrenderer.cpp#L371</a><br>msDrawQueryLayer later calls msDrawShape here:<br><a href="https://github.com/mapserver/mapserver/blob/3e8aa5a4d92c9bad105306ebe5117ed29d2b0e7c/mapdraw.c#L1295" target="_blank">https://github.com/mapserver/mapserver/blob/bdd421c7e69e2ff16841c12c08ba688b62a9f9a6/mapdraw.c#L1299</a><br>which eventually results in a call to KmlRenderer::renderGlyphs<br><a href="https://github.com/mapserver/mapserver/blob/3e8aa5a4d92c9bad105306ebe5117ed29d2b0e7c/mapkmlrenderer.cpp#L693" target="_blank">https://github.com/mapserver/mapserver/blob/bdd421c7e69e2ff16841c12c08ba688b62a9f9a6/mapkmlrenderer.cpp#L693</a><br>which gets to KmlRenderer::createPlacemarkNode and reuses the reference that was set:<br><a href="https://github.com/mapserver/mapserver/blob/3e8aa5a4d92c9bad105306ebe5117ed29d2b0e7c/mapkmlrenderer.cpp#L585" target="_blank">https://github.com/mapserver/mapserver/blob/bdd421c7e69e2ff16841c12c08ba688b62a9f9a6/mapkmlrenderer.cpp#L585</a><br>even though that temporary layer was freed earlier, leading to the crash.<br><br></div><div>And one with WMS:<br><br>It crashes around here:<br><a href="https://github.com/mapserver/mapserver/blob/3e8aa5a4d92c9bad105306ebe5117ed29d2b0e7c/mapdraw.c#L106" target="_blank">https://github.com/mapserver/mapserver/blob/bdd421c7e69e2ff16841c12c08ba688b62a9f9a6/mapdraw.c#L106</a><br></div>Probably due to trying to set NULL-><span class="">map</span>... That error message should probably be moved before that line.<br>In my case though, I was trying to serve KML over WMS, so "not having an image" shouldn't really be an error condition? And that non-square-pixels thing also shouldn't be relevant for vector layers; currently the dimensions of the requested WMS "image" have a big effect on KML output coordinates, which strikes me as broken, so perhaps that whole function should be avoided for vector output.<br></div>