|
Message-ID: <3047d23aacd2b058c5f6c40cd45f8511@smtp.hushmail.com> Date: Tue, 16 Apr 2013 20:06:23 +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) Fix is committed now. I also fixed the bug below. This one actually exist in core too, although I'm not sure any core format uses mem_alloc_tiny() for SSE2 buffers. #if ARCH_ALLOWS_UNALIGNED - if (mem_saving_level > 2) + if (mem_saving_level > 2 && align != MEM_ALIGN_SIMD) align = MEM_ALIGN_NONE; #endif magnum On 16 Apr, 2013, at 19:40 , magnum <john.magnum@...hmail.com> wrote: > 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.