Re: [HACKERS] patch for memory overrun on Linux(i386)

From: Massimo Dal Zotto <dz(at)cs(dot)unitn(dot)it>
To: hackers(at)postgreSQL(dot)org (Pgsql Development)
Subject: Re: [HACKERS] patch for memory overrun on Linux(i386)
Date: 1998-03-26 15:16:55
Message-ID: 199803261516.QAA02568@nikita.wizard.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> > >From the linux man page:
> > For calloc() and malloc(), the value returned is a pointer
> > to the allocated memory, which is suitably aligned for any
> > kind of variable, or NULL if the request fails.
>
> OK, then why is electric fence telling him to make DOUBLEALIGN match
> INTALIGN? You would think that if this change made sense, we would be
> having some Linux problems, but we don't.
>
> ---------------------------------------------------------------------------
>
>
> #if ! defined(sco)
> #define DOUBLEALIGN(LEN)\
> (((long)(LEN) + (sizeof (double) - 1)) & ~(sizeof (double) -1))
>
> #define MAXALIGN(LEN)\
> (((long)(LEN) + (sizeof (double) - 1)) & ~(sizeof (double) -1))
> #else
> #define DOUBLEALIGN(LEN) INTALIGN(LEN)
> #define MAXALIGN(LEN) INTALIGN(LEN)
> #endif
>

Hi Hackers,

it seems that Linux malloc, or better libc-5.4.23 malloc, is doing what is
declared in the man page, i.e. returning "memory which is suitably aligned
for any kind of variable". I have some malloc traces and all malloc results
are aligned to double size (8 bytes):

op caller ptr size
--------------------------------------------
malloc 400c32b2 080a06c8 25
malloc 400c32b2 080a06e8 13
malloc 400c32b2 080a0700 26
malloc 400c32b2 080a0720 11
malloc 400c32b2 080a0730 50
malloc 400c32b2 080a0768 14
malloc 400c32b2 080a0780 17
malloc 400c32b2 080a0798 24
malloc 400c32b2 080a07b8 27
malloc 400c32b2 080a07d8 817
malloc 400c32b2 080a0b10 11
malloc 400c32b2 080a0b20 14
malloc 400c32b2 080a0b38 164
malloc 400c32b2 080a0be0 11
malloc 400c32b2 080a0bf0 14
malloc 400c32b2 080a0c08 25
malloc 400c32b2 080a0c28 16
malloc 400c32b2 080a0c40 35
malloc 400c32b2 080a0c68 9
malloc 400c32b2 080a0c78 7

So I don't see where is the problem.

Massimo Dal Zotto

+----------------------------------------------------------------------+
| Massimo Dal Zotto e-mail: dz(at)cs(dot)unitn(dot)it |
| Via Marconi, 141 phone: ++39-461-534251 |
| 38057 Pergine Valsugana (TN) www: http://www.cs.unitn.it/~dz/ |
| Italy pgp: finger dz(at)tango(dot)cs(dot)unitn(dot)it |
+----------------------------------------------------------------------+

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas G. Lockhart 1998-03-26 15:18:34 Re: [HACKERS] symbol ':'
Previous Message Jose' Soares Da Silva 1998-03-26 14:10:49 Re: AW: [HACKERS] Begin statement again