public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] Debug Malloc Problem
@ 2009-05-26 18:48 Nathan Wharton
  2009-05-26 18:50 ` Nathan Wharton
  0 siblings, 1 reply; 12+ messages in thread
From: Nathan Wharton @ 2009-05-26 18:48 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

Sorry, looks like I didn't reply all on this one:


On Fri, May 22, 2009 at 11:31 PM, Marek Lindner <lindner_marek@yahoo.de> wrote:
>> I am getting set up to do remote debugging.  I'll see what I can find
>> doing that.
>
> Yeah, that would be another option.

ok, here is what I found on the debug malloc problem I am having:

In the function debugMalloc:
=================================
       chunkHeader = (struct chunkHeader *)memory;
       chunk = memory + sizeof(struct chunkHeader);
       chunkTrailer = (struct chunkTrailer *)(memory + sizeof(struct
chunkHeader) + length);

       chunkHeader->length = length;
       chunkHeader->tag = tag;
       chunkHeader->magicNumber = MAGIC_NUMBER;

       chunkTrailer->magicNumber = MAGIC_NUMBER;

=>      pthread_mutex_lock(&chunk_mutex);
=================================
I get the following results:

(gdb) p chunkHeader
$26 = (struct chunkHeader *) 0x308c8
(gdb) p chunk
$27 = (unsigned char *) 0x308d8 "\020\322\n"
(gdb) p chunkTrailer
$28 = (struct chunkTrailer *) 0x308dd
(gdb) p *chunkHeader
$29 = {next = 0x40096c34, length = 5, tag = 15, magicNumber = 305419896}
(gdb) p *chunkTrailer
$30 = {magicNumber = 878082050}
(gdb) p length
$31 = 5

I think the magic number is not getting into the chunk trailer
correctly because it is not aligned.
chunkHeader is aligned because it was returned by malloc
chunk is aligned because the size of the header is 16
chunkTrailer is not aligned because it is chunk + 5

Hope this helps.  If not, and that shouldn't be a problem, I'll see
what else I can find.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-05-27 17:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-26 18:48 [B.A.T.M.A.N.] Debug Malloc Problem Nathan Wharton
2009-05-26 18:50 ` Nathan Wharton
2009-05-26 22:13   ` Sven Eckelmann
2009-05-27  0:06     ` Nathan Wharton
2009-05-27  9:28       ` Marek Lindner
2009-05-27 14:20     ` Nathan Wharton
2009-05-27 16:07       ` Nathan Wharton
2009-05-27 16:16       ` Sven Eckelmann
2009-05-27 16:21         ` Nathan Wharton
2009-05-27 16:35           ` Nathan Wharton
2009-05-27 17:13             ` Sven Eckelmann
2009-05-27 17:21               ` Nathan Wharton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox