<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi,</p>
<p>didn't hear about Scudo before, but it seems it is a LLVM side
project: <a class="moz-txt-link-freetext" href="https://llvm.org/docs/ScudoHardenedAllocator.html">https://llvm.org/docs/ScudoHardenedAllocator.html</a></p>
<p>So perhaps you could build and use it on Linux as shown in
<a class="moz-txt-link-freetext" href="https://llvm.org/docs/ScudoHardenedAllocator.html#library">https://llvm.org/docs/ScudoHardenedAllocator.html#library</a></p>
<p>Besides a potential bug in the allocator, it might be that the
S57 driver has a memory allocation pattern that doesn't please
Scudo.</p>
<p>Assuming that the problematic memory allocations are done using
GDAL's VSIMalloc() (and not C++ new/delete), then have a look at
the various #define that you can set at the top of
port/cpl_vsisimple.cpp and can be used to trace memory allocations<br>
</p>
<p>// Uncomment to check consistent usage of VSIMalloc(),
VSIRealloc(),<br>
// VSICalloc(), VSIFree(), VSIStrdup().<br>
// #define DEBUG_VSIMALLOC<br>
<br>
// Uncomment to compute memory usage statistics.<br>
// DEBUG_VSIMALLOC must also be defined.<br>
// #define DEBUG_VSIMALLOC_STATS<br>
<br>
// Uncomment to print every memory allocation or deallocation.<br>
// DEBUG_VSIMALLOC must also be defined.<br>
// #define DEBUG_VSIMALLOC_VERBOSE<br>
<br>
// Number of bytes of the malloc/calloc/free that triggers a debug
trace.<br>
// Can be 0 for all allocs.<br>
#define THRESHOLD_PRINT 10000<br>
<br>
Even<br>
<br>
<br>
</p>
<div class="moz-cite-prefix">Le 28/03/2022 à 14:58, Philippe Lelong
a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:4a02d507464245a9927fa96256baf66e@meltemus.com">
<div id="divtagdefaultwrapper" dir="ltr">
<p>Hi,</p>
<p><br>
</p>
<p><span>I am searching for this issue for months now, and
cannot find any solution.</span><br>
</p>
<p><br>
To make a long story short, we are using GDAL to decode
OGR/S57 charts for years now. We are facing numerous crashes
under Android 11 and up if and only if this Android 11
implementation is using SCUDO as a memory allocator (if
jemalloc is used no problems). We face this problem with an
old GDAL2.1.3 version, so we updated to GDAL 3.4.1 but the
issue is the same.</p>
<p><br>
</p>
<p>What I can see is that the memory grows exponentially until
no more memory is available and crash, even on systems with
huge memory available while an Android device without SCUDO
and very limited memory (let's say 4Gb) in the same
exact conditions, with the same apk, runs perfectly. The
logcat command show this:</p>
<p> </p>
<div><span>03-28 12:40:34.255 4959 5005 W libc :
malloc(264196) failed: returning null pointer</span><br>
</div>
<div>03-28 12:40:34.255 4959 5005 W libc : malloc(264196)
failed: returning null pointer</div>
<div>03-28 12:40:34.256 4959 5005 W libc : malloc(264196)
failed: returning null pointer</div>
<div>03-28 12:40:34.256 4959 5005 W libc : malloc(264196)
failed: returning null pointer</div>
<div>03-28 12:40:34.612 630 630 D io_stats: !@
Write_top(KB): kworker/u16:1(32583) 8</div>
<div>03-28 12:40:34.820 4959 5041 I scudo : Scudo ERROR: out
of memory trying to allocate 64 bytes</div>
<div>03-28 12:40:34.820 4959 5042 I scudo : Scudo ERROR: out
of memory trying to allocate 64 bytes</div>
<div>03-28 12:40:34.820 4959 5033 I scudo : Scudo ERROR: out
of memory trying to allocate 64 bytes</div>
<div>03-28 12:40:34.820 4959 5031 I scudo : Scudo ERROR: out
of memory trying to allocate 64 bytes</div>
<div>03-28 12:40:34.820 4959 5038 I scudo : Scudo ERROR: out
of memory trying to allocate 64 bytes</div>
<div>03-28 12:40:34.820 4959 5040 I scudo : Scudo ERROR: out
of memory trying to allocate 64 bytes</div>
<div><br>
</div>
<div>and then crash</div>
<div><br>
</div>
<div>Any help on how to debug and eventually fix this would be
highly appreciated.</div>
<div><br>
</div>
<div>Best regards,</div>
<div>Philippe from qtVlm development team.</div>
<div><br>
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>