Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group