<div dir="auto">Assuming you’re interpreting this correctly then I agree with you. I’ve not used assertions personally. </div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 11, 2022 at 1:09 PM Tamas Szekeres <<a href="mailto:szekerest@gmail.com">szekerest@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Devs,<div><br></div><div>We are experiencing frequent crashes in the mapserver codebase in a heavy loaded runtime environment that causes the entire host process to exit regularly. According to the crash report it mostly points to the following location:</div><div><br></div><div><i>static int msOGRGetPaging(layerObj *layer)<br>{<br>#ifdef USE_OGR<br> msOGRFileInfo *layerinfo = NULL;<br><br> if (layer->debug) {<br> msDebug("msOGRGetPaging called.\n");<br> }<br><br> if(!msOGRLayerIsOpen(layer))<br> msOGRLayerOpenVT(layer);<br><br> <font color="#ff0000">assert( layer->layerinfo != NULL); <<<<< assert is happenting here</font><br><br> layerinfo = (msOGRFileInfo *)layer->layerinfo;<br> <font color="#ff0000"> return layerinfo->bPaging; <<<<< crash is happening here</font><br>#else<br> msSetError( MS_MISCERR,<br> "OGR support is not available.",<br> "msOGREnablePaging()");<br> return MS_FAILURE;<br>#endif<br>}</i><br></div><div><br></div><div>I just wanted to ask, what do folks think about this practice? It looks like the author of the code thinks that something will happen in the assertion to prevent the code to execute the next statements. However the assert check does no op in a production build or in a process that is not attached to a debugger session. As far as I can imagine the code should programmatically handle the asserted situation and do something useful if in our case layer->layerinfo is NULL. </div><div>As far as I see, the current codebase is full of such preconception that assert stops the operation (or exits the function, whatever?) and we should do nothing special when the condition is met.</div><div><br></div><div>Any thoughts?</div><div><br></div><div>Tamas</div><div><br></div><div><br></div><div><br></div><div> </div></div>
_______________________________________________<br>
MapServer-dev mailing list<br>
<a href="mailto:MapServer-dev@lists.osgeo.org" target="_blank">MapServer-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/mapserver-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/mapserver-dev</a><br>
</blockquote></div></div>