Hi Simon,<div><br></div><div>Thanks for the patch. Now it takes a bit longer ... but it ends up by returning NULL anyway. The above program didn&#39;t change.</div><div><br></div><div>&gt; spawnd.0: spawning /x86_64/sbin/myapp on core 0</div>
<div><div>
myapp.0 in main() ../barrelfish/usr/tests/myapp/myapp.c:12</div><div>malloc() returned NULL at 30710</div><div>Aborted</div><div><br></div><div><br></div><div>To add originality to the situation, sometimes I get this error too:</div>
<div><br></div><div><div>ERROR: mem_serv.0 in mem_lmp_default_error_handler() ./x86_64/lib/barrelfish/_for_lib_barrelfish/mem_flounder_bindings.c:1328</div><div>ERROR: asynchronous error in Flounder-generated mem lmp binding (default handler)</div>
<div>Failure: (  libbarrelfish) Failure in lmp_chan_alloc_recv_slot() [LIB_ERR_LMP_ALLOC_RECV_SLOT]</div><div>Failure: (  libbarrelfish) Failure in slot_alloc() [LIB_ERR_SLOT_ALLOC]</div><div>Failure: (  libbarrelfish) Failure in cnode_create() [LIB_ERR_CNODE_CREATE]</div>
<div>Failure: (  libbarrelfish) Failure in ram_alloc() [LIB_ERR_RAM_ALLOC]</div><div>Failure: (          libmm) No matching node found [MM_ERR_NOT_FOUND]</div><div>Aborted</div></div><div><br></div><div><br></div><div>To give you some hints about the first error, it fails when calling to vspace_mmu_aware_map() in morecore.c:59 with error LIB_ERR_FRAME_CREATE_MS_CONSTRAINTS. It turns out that (step &lt; BASE_PAGE_SIZE). As this is the first call to that function in the loop, the buffer is NULL.</div>
<div><br></div><div>As I see, in the latest version the debug_err() has been removed when reaching this condition.</div><div><br></div><div><br></div><div>Thanks for your help,</div><div>zeus.</div><div><br></div><div><br>
</div><div class="gmail_quote">
El 22 de septiembre de 2011 16:25, Simon Peter <span dir="ltr">&lt;<a href="mailto:speter@inf.ethz.ch" target="_blank">speter@inf.ethz.ch</a>&gt;</span> escribió:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

I think I found the issue. Here&#39;s a patch:<br>
<br>
diff -r 215f069a289c lib/barrelfish/vspace/mmu_<u></u>aware.c<br>
--- a/lib/barrelfish/vspace/mmu_<u></u>aware.c Tue Sep 20 15:18:31 2011 +0200<br>
+++ b/lib/barrelfish/vspace/mmu_<u></u>aware.c Thu Sep 22 16:23:43 2011 +0200<br>
@@ -227,6 +227,7 @@<br>
<br>
     // Reduce offset<br>
     state-&gt;offset -= bytes;<br>
+    state-&gt;consumed -= bytes;<br>
     if (success) {<br>
         state-&gt;mapoffset = min_offset;<br>
     }<br>
<br>
 -- Simon<div><br>
<br>
On 22.09.2011 13:23, Zeus Gómez Marmolejo wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
I&#39;m running free() under the debugger and the x86_64 specific hack is<br>
not firing.<br>
<br>
It&#39;s going through lesscore() and then from a quick view it seems that<br>
is doing it ok:<br>
<br>
memobj_anon unfill(), calling to the x86_64 pmap unmap and then calling<br>
to the kernel vnode_unmap(). Finally track_frame_return()...<br>
<br>
I don&#39;t see anything wrong here, it seems it&#39;s not skipping anything...<br>
The curious thing is that the pointer returned by malloc() is always the<br>
same. So it &quot;seems&quot; that free is working correctly.<br>
<br>
The program is always stopping after allocating about 1Gb of memory,<br>
which is the size of the physical memory of the virtual machine....<br>
<br>
zeus.<br>
<br>
El 22 de septiembre de 2011 01:33, Baumann Andrew &lt;<a href="mailto:andrewb@inf.ethz.ch" target="_blank">andrewb@inf.ethz.ch</a><br></div>
&lt;mailto:<a href="mailto:andrewb@inf.ethz.ch" target="_blank">andrewb@inf.ethz.ch</a>&gt;&gt; escribió:<div><br>
<br>
    Hi Zeus,____<br>
<br>
    __ __<br>
<br>
    We’re really bad with reclaiming memory, but I didn’t know it was<br>
    that bad! Honestly, there’s no good reason I can see for our heap<br>
    being that broken. From the quick glance through the code<br>
    (lib/c/src/malloc.c) my guess is that either the x86_64-specific<br>
    hack to avoid freeing memory allocated on another core is firing<br>
    incorrectly, or lesscore() is firing and doing something dumb. Could<br>
    you check which it is?____<br>
<br>
    __ __<br>
<br>
    I’m CCing Simon, who should know more about the workings of<br>
    lesscore().____<br>
<br>
    __ __<br>
<br>
    Andrew____<br>
<br>
    __ __<br>
<br>
    *From:* Zeus Gómez Marmolejo [mailto:<a href="mailto:zeus.gomez@bsc.es" target="_blank">zeus.gomez@bsc.es</a><br>
    &lt;mailto:<a href="mailto:zeus.gomez@bsc.es" target="_blank">zeus.gomez@bsc.es</a>&gt;]<br>
    *Sent:* Wednesday, 21 September, 2011 6:14<br>
    *To:* <a href="mailto:barrelfish-users@lists.inf.ethz.ch" target="_blank">barrelfish-users@lists.inf.<u></u>ethz.ch</a><br></div>
    &lt;mailto:<a href="mailto:barrelfish-users@lists.inf.ethz.ch" target="_blank">barrelfish-users@<u></u>lists.inf.ethz.ch</a>&gt;<div><div></div><div><br>
    *Subject:* [Barrelfish-users] Bug in malloc()/free() ?____<br>
<br>
    __ __<br>
<br>
    Hi,____<br>
<br>
    __ __<br>
<br>
    Here I introduce you a pretty simple program:____<br>
<br>
    __ __<br>
<br>
    int main(int argc, char **argv)____<br>
<br>
    {____<br>
<br>
    void *p;____<br>
<br>
    int i;____<br>
<br>
    ____<br>
<br>
    for(i=0; ;i++)____<br>
<br>
    {____<br>
<br>
    p = malloc(65536);____<br>
<br>
    if (p==NULL)____<br>
<br>
    USER_PANIC(&quot;malloc() returned NULL at %d&quot;, i);____<br>
<br>
    free (p);____<br>
<br>
    }____<br>
<br>
    ____<br>
<br>
    return 0;____<br>
<br>
    }____<br>
<br>
    __ __<br>
<br>
    This is ALWAYS aborting as:____<br>
<br>
    __ __<br>
<br>
    ERROR: myapp.0 in morecore_alloc()<br>
    ../barrelfish/lib/barrelfish/<u></u>morecore.c:85____<br>
<br>
    ERROR: vspace_mmu_aware_map fail____<br>
<br>
    Failure: ( libbarrelfish) Out of space in vspace_mmu_aware_map()<br>
    function [LIB_ERR_VSPACE_MMU_AWARE_NO_<u></u>SPACE]____<br>
<br>
    myapp.0 in main() ../barrelfish/usr/tests/myapp/<u></u>myapp.c:12____<br>
<br>
    malloc() returned NULL at 16382____<br>
<br>
    Aborted____<br>
<br>
    __ __<br>
<br>
    With the latest Barrelfish tree. Are you aware of this?____<br>
<br>
    __ __<br>
<br>
    __ __<br>
<br>
    --<br>
    Zeus Gómez Marmolejo<br>
    Barcelona Supercomputing Center<br>
    PhD student<br>
    <a href="http://www.bsc.es" target="_blank">http://www.bsc.es</a><br>
<br>
    ____<br>
<br>
<br>
<br>
<br>
--<br>
Zeus Gómez Marmolejo<br>
Barcelona Supercomputing Center<br>
PhD student<br>
<a href="http://www.bsc.es" target="_blank">http://www.bsc.es</a><br>
<br>
<br>
</div></div></blockquote>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Zeus Gómez Marmolejo<br>Barcelona Supercomputing Center<br>PhD student<br><a href="http://www.bsc.es" target="_blank">http://www.bsc.es</a><br><br><br>
</div>