|
Message-ID: <00f5603f51c6fcb2e692d7fc3b025633@smtp.hushmail.com> Date: Tue, 16 Apr 2013 19:40:13 +0200 From: magnum <john.magnum@...hmail.com> To: john-dev@...ts.openwall.com Subject: Re: Segfaults probably caused by DEBUG code in memory.c (was: Segfault for linux-x86-native with -DDEBUG added) Yeah, this is it. My bad. The rationale was to make memory debugging a lot easier under -DDEBUG but it was really *supposed* to still maintain requested alignment. Sometimes I amaze myself :-( magnum On 16 Apr, 2013, at 18:34 , jfoug <jfoug@....net> wrote: > From: Frank Dittrich [mailto:frank_dittrich@...mail.com] >> >> No segfaults. >> So I guess the -DDEBUG code in memory.c causes memory locations to be not aligned as expected. > > void *mem_alloc_tiny(size_t size, size_t align) > { > #ifdef DEBUG > void *res; > > +++ res = mem_alloc(size); > add_memory_link(res); > return res; > #else > > The line with +++. There is there assurance of alignment? Or do we need to allocate size+align, use that pointer in the add_memory_link, and then 'fix' the pointer? > > > void *mem_alloc_tiny(size_t size, size_t align) > { > #ifdef DEBUG > void *res; > > res = mem_alloc(size+align); > add_memory_link(res); > res += (align-1); > res -= (size_t)(res & (align-1)); > return res; > #else > > Look at the bottom of the mem_alloc_tiny. IT does not use the return from mem_alloc (which is return from malloc), but fixes it up. > > p = mem_alloc(size + mask); > add_memory_link((void*)p); > p += mask; > p -= (size_t)p & mask; > return p; > >
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.