mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: malloc testing
Date: Thu, 21 Apr 2011 02:00:57 -0400	[thread overview]
Message-ID: <20110421060057.GR277@brightrain.aerifal.cx> (raw)
In-Reply-To: <4DAF9259.10300@gmail.com>

On Thu, Apr 21, 2011 at 09:11:37AM +0700, JIghtuse wrote:
> On 20.04.2011 11:34, Rich Felker wrote:
> >On Sun, Apr 10, 2011 at 10:59:08PM +0700, JIghtuse wrote:
> >>I have some questions about my task. I've written a program to test
> >>malloc() function of musl. But..
> >Any updates? Are you still interested in working on this?
> >
> >Ricih
> Yes, I interested in. Just some studying.
> Can you give some algorithms? I not found its on the Net. How chunks
> should be flipped?

Try something like:

1. Allocate blocks in random sizes until the total size exceeds the
configured limit M. For each block allocated, keep track of its
address and size.

2. Sort the allocated block records by size (with the qsort function).

3. Free all but the first 25% in the sorted list (i.e. all but the
smallest ones). Leave the ones you don't free in your list.

Repeat this procedure a few times, and the last time through, don't
free anything. Now sort the records by address instead of by size, and
check that they don't overlap.

For large allocations (>100k) I would bias the random numbers to be
just below a multiple of 4096. Something like:

if (size > 100000) size |= 0xff0;

This puts them in the "red zone" where bugs could (and in the past
did) lead to under-allocation.

Rich


  reply	other threads:[~2011-04-21  6:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-10 15:59 malloc testing (was: Simple testing task - string functions) JIghtuse
2011-04-20  4:34 ` malloc testing (was: Simple testing task - string Rich Felker
2011-04-21  2:11   ` malloc testing JIghtuse
2011-04-21  6:00     ` Rich Felker [this message]
2011-04-27  3:24 JIghtuse
2011-04-29  5:42 ` Solar Designer
2011-06-04 18:03   ` JIghtuse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110421060057.GR277@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).