<div dir="ltr"><div>I hate that.</div><div>I never use "long" exactly for that problem. When the size is important, uint64_t and friends are very useful, and well defined.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 8 Mar 2024 at 10:16, Abel Pau via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg-8810667449520614645">





<div lang="CA">
<div class="m_-8810667449520614645WordSection1">
<p class="MsoNormal"><span lang="ES" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">FINALLY!<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="ES" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">I discovered the problem.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="ES" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">I was using “unsigned long” as 4 bytes variable. On windows it’s like that.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">BUT on linux this kind of variable has a 8-bytes size.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">This caused a mess in linux (but not in wondows).<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">So, mistery closed!!!!!<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">Thanks you all.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<div>
<div style="border-width:1pt medium medium;border-style:solid none none;border-color:rgb(225,225,225) currentcolor currentcolor;padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span lang="ES" style="font-size:11pt;font-family:"Calibri",sans-serif">De:</span></b><span lang="ES" style="font-size:11pt;font-family:"Calibri",sans-serif"> gdal-dev <<a href="mailto:gdal-dev-bounces@lists.osgeo.org" target="_blank">gdal-dev-bounces@lists.osgeo.org</a>>
<b>En nombre de </b>Abel Pau via gdal-dev<br>
<b>Enviado el:</b> dijous, 7 de març de 2024 23:42<br>
<b>Para:</b> Even Rouault <<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>>; Andrew C Aitchison <<a href="mailto:andrew@aitchison.me.uk" target="_blank">andrew@aitchison.me.uk</a>>; Daniel Evans <<a href="mailto:daniel.fred.evans@gmail.com" target="_blank">daniel.fred.evans@gmail.com</a>><br>
<b>CC:</b> '<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>' (<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>) <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>><br>
<b>Asunto:</b> Re: [gdal-dev] Testing the driver<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span lang="ES" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">It’s in debug mode, yes, as you suggested.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">yes, it crashes in the same way. Same big number.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">It crashes because of the variable is not read from the file (this variable should be 1).<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">But debugging in windows (where not crashes) this variable is set when opening the layer, and then I suppose has the value
 corrupted at some point.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">So I am going to put my old fashion printf on.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)">Thanks again!<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<div>
<div style="border-width:1pt medium medium;border-style:solid none none;border-color:rgb(225,225,225) currentcolor currentcolor;padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span lang="ES" style="font-size:11pt;font-family:"Calibri",sans-serif">De:</span></b><span lang="ES" style="font-size:11pt;font-family:"Calibri",sans-serif"> Even Rouault <<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>>
<br>
<b>Enviado el:</b> dijous, 7 de març de 2024 23:32<br>
<b>Para:</b> Abel Pau <<a href="mailto:a.pau@creaf.uab.cat" target="_blank">a.pau@creaf.uab.cat</a>>; Andrew C Aitchison <<a href="mailto:andrew@aitchison.me.uk" target="_blank">andrew@aitchison.me.uk</a>>; Daniel Evans <<a href="mailto:daniel.fred.evans@gmail.com" target="_blank">daniel.fred.evans@gmail.com</a>><br>
<b>CC:</b> '<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>' (<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>) <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>><br>
<b>Asunto:</b> Re: [gdal-dev] Testing the driver<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<blockquote style="margin-top:5pt;margin-bottom:5pt">
<pre><u></u> <u></u></pre>
<pre>At #10 we can see the variable nNum set to a non-sense megabignumber.<u></u><u></u></pre>
</blockquote>
<p>Is it on a -DCMAKE_BUILD_TYPE=Debug build ? Otherwise stack traces and variable content in the debugger might look like garbage because of optimizations.<u></u><u></u></p>
<p>If it is a debug build, then there's likely some memory corruption or uninitialized variable in your code. Valgrind is generally a great tool to spot that. Otherwise add good old printf() statements to track down where the corruption starts. And given your
 Python sample code, I assume you could more easily reproduce the issue in a pure native context, just running "ogrinfo -al -q autotest/ogr/data/miramon/Polygons/SimplePolygons/SimplePolFile.pol" (if it doesn't crash, try running it under gdb or valgrind)<u></u><u></u></p>
<pre>-- <u></u><u></u></pre>
<pre><a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a><u></u><u></u></pre>
<pre>My software is free, but my time generally not.<u></u><u></u></pre>
</div>
</div>

_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</div></blockquote></div>