From patchwork Tue May 26 18:50:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nathan Wharton X-Patchwork-Id: 5378 Received: from mail-qy0-f103.google.com (mail-qy0-f103.google.com [209.85.221.103]) by open-mesh.net (8.14.3/8.13.4/Debian-3sarge3) with ESMTP id n4QJ7lYT016640 for ; Tue, 26 May 2009 19:07:49 GMT Received: by qyk1 with SMTP id 1so5416385qyk.16 for ; Tue, 26 May 2009 11:50:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.71.20 with SMTP id f20mr4403238vcj.70.1243363856282; Tue, 26 May 2009 11:50:56 -0700 (PDT) In-Reply-To: <4313f3060905261148t14ea24bcq6f2ebca3e1007106@mail.gmail.com> References: <4313f3060905261148t14ea24bcq6f2ebca3e1007106@mail.gmail.com> Date: Tue, 26 May 2009 13:50:56 -0500 Message-ID: <4313f3060905261150o6c9fe82at6dd40d26456ac03a@mail.gmail.com> From: Nathan Wharton To: The list for a Better Approach To Mobile Ad-hoc Networking Subject: [B.A.T.M.A.N.] Debug Malloc Problem X-BeenThere: b.a.t.m.a.n@open-mesh.net X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 May 2009 19:07:49 -0000 Looks like this one didn't go to all either. Sorry for the mess. On Tue, May 26, 2009 at 10:47 AM, Nathan Wharton wrote: > On Fri, May 22, 2009 at 11:31 PM, Marek Lindner 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. > I added the following patch: chunkTrailer)); */ ========================================= And I don't get any debug malloc problems anymore. I do, however, still get the kernel crashes when using batgat. ========================================= --- batmand-r1269/batman/allocate.c     2009-05-20 13:54:18.000000000 -0500 +++ batmand-r1269.mod/batman/allocate.c 2009-05-26 12:25:07.000000000 -0500 @@ -206,6 +206,10 @@        struct chunkHeader *chunkHeader;        struct chunkTrailer *chunkTrailer;        unsigned char *chunk; +       uint32_t remainder = length % 4; + +       if (remainder > 0) +         length += 4 - remainder;  /*     printf("sizeof(struct chunkHeader) = %u, sizeof (struct chunkTrailer) = %u\n", sizeof (struct chunkHeader), sizeof (struct