|
|
Message-ID: <003901ce3ac0$3a4eaed0$aeec0c70$@net>
Date: Tue, 16 Apr 2013 11:34:12 -0500
From: "jfoug" <jfoug@....net>
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)
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.