<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 7 August 2018 at 13:22, Ben Coman <span dir="ltr"><<a href="mailto:btc@openinworld.com" target="_blank">btc@openinworld.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Next is to try loading an Image.</div></div></div></div></blockquote><div><br></div><div>+ Downloaded and unzipped 

<a href="http://files.pharo.org/image/70/latest-minimal-64.zip" rel="noreferrer" style="color:rgb(17,85,204);font-size:12.8px;background-color:rgb(255,255,255)" target="_blank">http://files.pharo.org/image/7<wbr>0/latest-minimal-64.zip</a>

</div><div>+ In Visual Studio, right-clicked CMakeLists.txt > Debug and Launch Settings > pharo.exe</div><div>+ Edited the presented "launch.vs.json" as follows...</div><div><div>{</div><div>  "version": "0.2.1",</div><div>  "defaults": {},</div><div>  "configurations": [</div><div>    {</div><div>      "type": "default",</div><div>      "project": "CMakeLists.txt",</div><div>      "projectTarget": "pharo.exe (dist\\pharo.exe)",</div><div>      "name": "pharo.exe with image (dist\\pharo.exe)",</div><div>      "args": [</div><div>        "C:\\#Dev\\latest-minimal-64\\Pharo7.0-metacello-64bit-65cff7b.image",</div><div>        "s"</div><div>      ]</div><div>    },</div><div>  ]</div><div>}</div></div><div><br></div><div>Now running "x64-Debug" and <span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">"pharo.exe with image"</span></div><div>I find it gets hung up in...</div><div>    sqAllocateMemory(usqInt minHeapSize, usqInt desiredHeapSize)</div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">

<div style="text-decoration-style:initial;text-decoration-color:initial">in call...</div><div style="text-decoration-style:initial;text-decoration-color:initial">   alloc = sqAllocateMemorySegmentOfSizeAboveAllocatedSizeInto (roundUpToPage(desiredHeapSize), address, &allocBytes);</div><div style="text-decoration-style:initial;text-decoration-color:initial">with...</div></span></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">    desiredHeapSize ==> 39583744 (~39MB)</span></div><div>    address ==> 0x00007ff7d6e00000</div><div><br></div><div>where inside that call... </div><div>  void *sqAllocateMemorySegmentOfSizeAboveAllocatedSizeInto(sqInt size, void *minAddress, sqInt *allocatedSizePointer)"<br></div><div>has... </div><div>    size ==> 39583744</div><div>    minAddress ==> 0x00007ff7d6e00000</div><div>    address ==> 0x00000000d6e00000</div><div>    bytes ==> 39583744
<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">(~39MB)</span>

</div><div>    delta ==> 1048576</div><div><br></div><div>it gets stuck the following loop...  <a href="https://github.com/bencoman/opensmalltalk-vm/blob/8231b96f9b/platforms/win32/vm/sqWin32SpurAlloc.c#L139-L183">https://github.com/bencoman/opensmalltalk-vm/blob/8231b96f9b/platforms/win32/vm/sqWin32SpurAlloc.c#L139-L183</a></div><div><br></div><div>    while ((usqIntptr_t)(address + bytes) > (usqIntptr_t)address)</div><div>    {    alloc = VirtualAlloc(address, bytes, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);</div><div>         ...</div><div>         if (alloc >= (char *)minAddress) && (alloc <= address + delta))  return alloc;</div><div>         ...</div><div>         address += delta;</div><div>    }</div><div><br></div><div>where... <br></div><div>    alloc ==> 0x00000000d6e00000</div><div>    (alloc >= (char *)minAddress) ==> false.<br></div><div><br></div><div>which is effectively...  (do<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">es this seem normal?)</span></div><div>      ((char *)minAddress-address)/delta ==> 134,180,864 loops before exit.<br></div><div>

<div style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br></div></div><div>but... </div><div><div style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">    (alloc >= (char *)address) ==> true.<br></div><div style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">would exit on the first pass of the loop, except... <span style="white-space:pre">  </span></div><div style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">    /* For some reason (large page support?) we can ask for a page-aligned</div><div>     * address such as 0xNNNNf000 but VirtualAlloc will answer 0xNNNN0000.</div><div>     * So accept allocs above minAddress rather than allocs above address</div><div>     */</div><div style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br></div><div class="gmail_quote" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div>where back one level "minAddress" is derived like this...</div></div><div class="gmail_extra" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">    /* choose a suitable starting point. In MinGW the malloc heap is below the</div><div class="gmail_extra" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">     * program, so take the max of a malloc and something form uninitialized</div><div class="gmail_extra" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">     * data.</div><div class="gmail_extra" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">     */</div><div class="gmail_extra" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="white-space:pre"> </span>hint = malloc(1);</div><div class="gmail_extra" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="white-space:pre">       </span>free(hint);</div><div class="gmail_extra" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="white-space:pre">     </span>hint = max(hint,(char *)&fIsConsole);</div>

<div>        address = (char *)(((usqInt)hint + alignment - 1) & ~(alignment - 1));</div><div>        address passed-by-value into minAddress </div></div><div><br></div><div><br></div><div>Now I'm out of my depth trying to understand the background on that logic,</div><div>but if I blindly change the loop exit condition </div><div>from...</div><div>    

<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">(alloc >= (char *)minAddress)</span>

</div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">to...</span></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">    

<span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">(alloc >= (char *)address)</span>

</span></div><div><br></div><div>then  osvm_loadImage(tempImageNameAttempt()</div><div>and subsequently  osvm_loadDefaultImage()  succeed.  </div><div><br></div><div>So some expert attention would be good here (as time permits) </div><div>In the meantime, I'll forge ahead to play with  osvm_run();</div><div><br></div><div>cheers -ben</div><div><br></div><div><br></div><div>P.S. making "#define printProbes 1"  and "fIsConsole = 1;"<div style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">shows...</div><div style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div>probing [00000000D6E00000,00000000D93C0000)</div><div>probing [00000000D6F00000,00000000D94C0000)</div><div>probing [00000000D7000000,00000000D95C0000)</div><div>probing [00000000D7100000,00000000D96C0000)</div><div>probing [00000000D7200000,00000000D97C0000)</div><div>probing [00000000D7300000,00000000D98C0000)</div><div>probing [00000000D7400000,00000000D99C0000)</div><div>probing [00000000D7500000,00000000D9AC0000)</div><div>probing [00000000D7600000,00000000D9BC0000)</div><div><br></div></div>

</div></div></div></div>