From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/266 Path: news.gmane.org!not-for-mail From: JIghtuse Newsgroups: gmane.linux.lib.musl.general Subject: malloc testing (was: Simple testing task - string functions) Date: Sun, 10 Apr 2011 22:59:08 +0700 Message-ID: <4DA1D3CC.1090008@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; X-Trace: dough.gmane.org 1312595694 11348 80.91.229.12 (6 Aug 2011 01:54:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 6 Aug 2011 01:54:54 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: envelope-from@hidden Sun Apr 10 19:59:34 2011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; DomainKey-Signature: a=rsa-sha1; c=nofws; User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20110307 Icedove/3.0.11 Xref: news.gmane.org gmane.linux.lib.musl.general:266 Archived-At: This is a multi-part message in MIME format. --------------000302000502000803090808 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit -------- Original Message -------- Subject: Re: [musl] Simple testing task - string functions Date: Sun, 10 Apr 2011 22:25:59 +0700 From: JIghtuse To: musl@lists.openwall.com I have some questions about my task. I've written a program to test malloc() function of musl. But.. 1. Can I use standart rand() and srand() functions to generate random size of allocated memory chunks, or I must to write another one random number generator? 2. Write a program which loops many times allocating and freeing memory So, when my program must to free memory? If it freeing just after its allocating, it always gets one chunk of memory. And how to define maximum size of memory chunk? I define it as MAX_SIZE / 1000, where MAX_SIZE is a maximum total allocated amount (about 8 * 10^8). Is it correctly? 3. I decided to generate a fragmentation diagram as a .dat file for plotting by gnuplot. Are you satisfied with it, or maybe write it as a simple text file with pseudo-graphic diagram? Thanks. I await your reply. UPD. I'm sorry for mixed tho threads, its really bad. -- Sincerely yours, JIghtuse. --------------000302000502000803090808 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit

-------- Original Message --------
Subject: Re: [musl] Simple testing task - string functions
Date: Sun, 10 Apr 2011 22:25:59 +0700
From: JIghtuse <jightuse@gmail.com>
To: musl@lists.openwall.com


I have some questions about my task. I've written a program to test 
malloc() function of musl. But..
1. Can I use standart rand() and srand() functions to generate random 
size of allocated memory chunks, or I must to write another one random 
number generator?
2.

Write a program which loops many times allocating and freeing memory

So, when my program must to free memory? If it freeing just after its 
allocating, it always gets one chunk of memory. And how to define 
maximum size of memory chunk? I define it as MAX_SIZE / 1000, where 
MAX_SIZE is a maximum total allocated amount (about 8 * 10^8). Is it 
correctly?
3. I decided to generate a fragmentation diagram as a .dat file for 
plotting by gnuplot. Are you satisfied with it, or maybe write it as a 
simple text file with pseudo-graphic diagram?
Thanks. I await your reply.


UPD. I'm sorry for mixed tho threads, its really bad.
-- 
Sincerely yours, JIghtuse.

--------------000302000502000803090808-- From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/294 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: malloc testing (was: Simple testing task - string Date: Wed, 20 Apr 2011 00:34:09 -0400 Message-ID: <20110420043409.GK277@brightrain.aerifal.cx> References: <4DA1D3CC.1090008@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1312595709 11486 80.91.229.12 (6 Aug 2011 01:55:09 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 6 Aug 2011 01:55:09 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: envelope-from@hidden Wed Apr 20 08:39:27 2011 Content-Disposition: inline In-Reply-To: <4DA1D3CC.1090008@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:294 Archived-At: 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? Rich From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/296 Path: news.gmane.org!not-for-mail From: JIghtuse Newsgroups: gmane.linux.lib.musl.general Subject: Re: malloc testing Date: Thu, 21 Apr 2011 09:11:37 +0700 Message-ID: <4DAF9259.10300@gmail.com> References: <4DA1D3CC.1090008@gmail.com> <20110420043409.GK277@brightrain.aerifal.cx> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1312595710 11492 80.91.229.12 (6 Aug 2011 01:55:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 6 Aug 2011 01:55:10 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: envelope-from@hidden Thu Apr 21 06:12:05 2011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; DomainKey-Signature: a=rsa-sha1; c=nofws; User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20110307 Icedove/3.0.11 In-Reply-To: <20110420043409.GK277@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:296 Archived-At: 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? -- Sincerely yours, JIghtuse. From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/297 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: malloc testing Date: Thu, 21 Apr 2011 02:00:57 -0400 Message-ID: <20110421060057.GR277@brightrain.aerifal.cx> References: <4DA1D3CC.1090008@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1312595710 11494 80.91.229.12 (6 Aug 2011 01:55:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 6 Aug 2011 01:55:10 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: envelope-from@hidden Thu Apr 21 10:06:25 2011 Content-Disposition: inline In-Reply-To: <4DAF9259.10300@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:297 Archived-At: 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