<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
I've now also results from testing different heap placements in the
SPIRAM address space.<br>
<br>
I've done these tests on branch "master" with duktape running on
core 1 (= no heap corruption crashes).<br>
<br>
To shift the duktape heap location into the upper SPIRAM regions, I
added this modification to DukTapeInit():<br>
<br>
<font face="monospace"><b> void *shiftmem =
ExternalRamMalloc(2*1024*1024);</b><br>
umm_memory = ExternalRamMalloc(memsize);<br>
<b> ESP_LOGI(TAG, "Duktape: shiftmem=%p umm_memory=%p",
shiftmem, umm_memory);</b><b><br>
</b><b> if (shiftmem) free(shiftmem);</b></font><br>
<br>
I've tried shifting into the upper 2 MB as shown here, and then
shifting by just 1 MB up to place the head at the upper end of the
lower 2 MB (so memory corruption by other processes is unlikely).
I've then run the event test script 15 times until aborted by the
error and collected the total loop counts.<br>
<br>
Result: there is a strong correlation between the heap memory half
used and the error frequency: with the heap in the upper half
(shifted by 2 MB), the loop will run <b>>10x longer</b> on
average than with the heap in the lower half.<br>
<br>
In absolute numbers: the average loop count with the heap in the
lower 2 MB SPIRAM was ~ 3,000, with the heap shifted into the upper
2 MB it was ~ 40,000.<br>
<br>
Within the lower half, there is no difference between shifting by 1
MB and no shifting, so it's most probably not caused by some other
process corrupting the duktape heap region.<br>
<br>
My conclusion would be now, this is still the SPIRAM bug, or a
previously undetected variant thereof. Can some others please try to
reproduce my results?<br>
<br>
Regards,<br>
Michael<br>
<br>
<br>
<div class="moz-cite-prefix">Am 17.09.21 um 10:56 schrieb Michael
Balzer:<br>
</div>
<blockquote type="cite"
cite="mid:693700a8-7c20-fc49-0c40-00f81e9c799d@expeedo.de"> I just
remembered…<br>
<br>
<a class="moz-txt-link-freetext"
href="https://github.com/espressif/esp-idf/issues/2892#issuecomment-459120605"
moz-do-not-send="true">https://github.com/espressif/esp-idf/issues/2892#issuecomment-459120605</a><br>
<br>
…and as Duktape runs on core #1, I now test shifting the Duktape
heap into the upper 2 MB of SPIRAM.</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26</pre>
</body>
</html>