Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 6 Aug 2011 13:15:05 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: New daily reports - debugging alloc.c et al

* Luka Mar??eti?? <paxcoder@...il.com> [2011-08-06 06:40:12 +0200]:
> here), but the method of allocation that I've been recommended
> either fails to fulfill its promise, or I'm blind to my own bug.
> Here's a minimal test case:
> http://paste.debian.net/125242/
> A quick explanation: Alloc.c needs to squat most of process' virtual
> memory. I employ a kind of binary search to find the greatest size
> that can be allocated, but then it turns out, mmap and malloc are
> able to continue allocating memory still. Not sure why.
> 

it works here as expected

the first loop finds the largest area that can be mmaped
(about 2.9G here)

then the second loop finds extra mmapable smaller regions
(this is slow here as there are about 70000 extra mmappable
pages, it would be better to do it in bigger chunks like:

    /*tries to mmap even more now:*/
    printf("Number of *additional* bytes mmap'd:\n");
    most=0;
    for(j=1<<20; j; j/=2) {
        printf("%8zu ", j);
        for(i=0; mmap(NULL, j*PAGE_SIZE, PROT_NONE, MAP_PRIVATE, fd, 0) != MAP_FAILED; ++i)
            printf(".");
        most += i*j*PAGE_SIZE;
        printf("\n");
    }
    printf("%zu\n", most);
)

after this the last loop with malloc immediately
fails (there is nothing to mmap anymore, but maybe
if the allocator already has some area reserved
then a few mallocs can succeed)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.