Ok, but I'm freeing all memory allocated my malloc() on each loop iteration. The max dynamic memory used by the program at any point is 64Kb... The program is basically this:<div><br></div><div>for (;;) {</div><div> p = malloc(65536);</div>
<div> free (p);</div><div>}<br><br><div class="gmail_quote">El 22 de septiembre de 2011 23:49, Timothy Roscoe <span dir="ltr"><<a href="mailto:troscoe@inf.ethz.ch">troscoe@inf.ethz.ch</a>></span> escribió:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Hi Zeus,<br>
<br>
At the risk of asking a very naive question,<br>
<div class="im"><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>
</div> - could this simply be a case of you running out of physical memory<br>
(Barrelfish doesn't overcommit memory, and does not page to disk), and<br>
Barrelfish being less than informative about the situation?<br>
<br>
-- Mothy<br>
<div><div></div><div class="h5"><br>
At Thu, 22 Sep 2011 19:33:49 +0200, Zeus Gómez Marmolejo <<a href="mailto:zeus.gomez@bsc.es">zeus.gomez@bsc.es</a>> wrote:<br>
> Hi Simon,<br>
><br>
> Thanks for the patch. Now it takes a bit longer ... but it ends up by<br>
> returning NULL anyway. The above program didn't change.<br>
><br>
> > spawnd.0: spawning /x86_64/sbin/myapp on core 0<br>
> myapp.0 in main() ../barrelfish/usr/tests/myapp/myapp.c:12<br>
> malloc() returned NULL at 30710<br>
> Aborted<br>
><br>
><br>
> To add originality to the situation, sometimes I get this error too:<br>
><br>
> ERROR: mem_serv.0 in mem_lmp_default_error_handler()<br>
> ./x86_64/lib/barrelfish/_for_lib_barrelfish/mem_flounder_bindings.c:1328<br>
> ERROR: asynchronous error in Flounder-generated mem lmp binding (default<br>
> handler)<br>
> Failure: ( libbarrelfish) Failure in lmp_chan_alloc_recv_slot()<br>
> [LIB_ERR_LMP_ALLOC_RECV_SLOT]<br>
> Failure: ( libbarrelfish) Failure in slot_alloc() [LIB_ERR_SLOT_ALLOC]<br>
> Failure: ( libbarrelfish) Failure in cnode_create() [LIB_ERR_CNODE_CREATE]<br>
> Failure: ( libbarrelfish) Failure in ram_alloc() [LIB_ERR_RAM_ALLOC]<br>
> Failure: ( libmm) No matching node found [MM_ERR_NOT_FOUND]<br>
> Aborted<br>
><br>
><br>
> To give you some hints about the first error, it fails when calling<br>
> to vspace_mmu_aware_map() in morecore.c:59 with error<br>
> LIB_ERR_FRAME_CREATE_MS_CONSTRAINTS. It turns out that (step <<br>
> BASE_PAGE_SIZE). As this is the first call to that function in the loop, the<br>
> buffer is NULL.<br>
><br>
> As I see, in the latest version the debug_err() has been removed when<br>
> reaching this condition.<br>
><br>
><br>
> Thanks for your help,<br>
> zeus.<br>
><br>
><br>
> El 22 de septiembre de 2011 16:25, Simon Peter <<a href="mailto:speter@inf.ethz.ch">speter@inf.ethz.ch</a>>escribió:<br>
><br>
> > I think I found the issue. Here's a patch:<br>
> ><br>
> > diff -r 215f069a289c lib/barrelfish/vspace/mmu_**aware.c<br>
> > --- a/lib/barrelfish/vspace/mmu_**aware.c Tue Sep 20 15:18:31 2011 +0200<br>
> > +++ b/lib/barrelfish/vspace/mmu_**aware.c Thu Sep 22 16:23:43 2011 +0200<br>
> > @@ -227,6 +227,7 @@<br>
> ><br>
> > // Reduce offset<br>
> > state->offset -= bytes;<br>
> > + state->consumed -= bytes;<br>
> > if (success) {<br>
> > state->mapoffset = min_offset;<br>
> > }<br>
> ><br>
> > -- Simon<br>
> ><br>
> ><br>
> > On 22.09.2011 13:23, Zeus Gómez Marmolejo wrote:<br>
> ><br>
> >> I'm running free() under the debugger and the x86_64 specific hack is<br>
> >> not firing.<br>
> >><br>
> >> It'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't see anything wrong here, it seems it's not skipping anything...<br>
> >> The curious thing is that the pointer returned by malloc() is always the<br>
> >> same. So it "seems" that free is working correctly.<br>
> >><br>
> >><br>
</div></div><div class="im">> >> zeus.<br>
> >><br>
> >> El 22 de septiembre de 2011 01:33, Baumann Andrew <<a href="mailto:andrewb@inf.ethz.ch">andrewb@inf.ethz.ch</a><br>
> >> <mailto:<a href="mailto:andrewb@inf.ethz.ch">andrewb@inf.ethz.ch</a>>> escribió:<br>
> >><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">zeus.gomez@bsc.es</a><br>
> >> <mailto:<a href="mailto:zeus.gomez@bsc.es">zeus.gomez@bsc.es</a>>]<br>
> >> *Sent:* Wednesday, 21 September, 2011 6:14<br>
</div>> >> *To:* barrelfish-users@lists.inf.**<a href="http://ethz.ch" target="_blank">ethz.ch</a><<a href="mailto:barrelfish-users@lists.inf.ethz.ch">barrelfish-users@lists.inf.ethz.ch</a>><br>
> >> <mailto:<a href="mailto:barrelfish-users@">barrelfish-users@</a>**<a href="http://lists.inf.ethz.ch" target="_blank">lists.inf.ethz.ch</a><<a href="mailto:barrelfish-users@lists.inf.ethz.ch">barrelfish-users@lists.inf.ethz.ch</a>><br>
<div><div></div><div class="h5">> >> ><br>
> >><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("malloc() returned NULL at %d", 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/**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_**SPACE]____<br>
> >><br>
> >> myapp.0 in main() ../barrelfish/usr/tests/myapp/**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>
> >><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>
</div></div></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>