Thread: Re: [HACKERS] patch for memory overrun on Linux(i386)
> >Of course on x86 there is no special requirement any type to be aligned at all. >Double do not need to be 8 byte aligned. Ints do not need to be on an even >address etc. So malloc can return a pointer to any address it wants on an x86 >and still conform to the restriction. Yes and I think it returns 4 byte aligned objects for performance reasons. (This is more efficient than storing double/int on 1/2 byte boundaries.) > >On a Sparc or an Alpha, objects must to be aligned to the sizeof the type. >So shorts are 2 byte aligned, ints 4 byte, and doubles 8 byte. Since malloc >has no idea what you are allocating it has to return an 8 byte aligned pointer. > >But all this is a bit of a red herring. The original bug if I recall was >caused by the caller assuming that the return from palloc was 8 byte aligned. >Since the caller "knew" that the pointer was 8 byte aligned it then went on >to do some "fancy" pointer arithmetic to arrive at an offset. This is what >is broken, not the Linux malloc(). Yes, I think so too. > >That said, I have a plan in mind to get a nice performance boost for palloc(). >As a side effect, I will guarantee 8 byte alignment of pointers returned >from palloc(). > Does this imply that more memory will be used that strictly necesary under linux? With regards from Maurice.
> >That said, I have a plan in mind to get a nice performance boost for > palloc(). > >As a side effect, I will guarantee 8 byte alignment of pointers returned > >from palloc(). > > > Does this imply that more memory will be used that strictly necesary under > linux? > > With regards from Maurice. Actually, perhaps less memory, because malloc memory is not aligned on double boundaries, but this is all still just conjecture. -- Bruce Momjian | 830 Blythe Avenue maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026 + If your life is a hard drive, | (610) 353-9879(w) + Christ can be your backup. | (610) 853-3000(h)
> > > >That said, I have a plan in mind to get a nice performance boost for > > palloc(). > > >As a side effect, I will guarantee 8 byte alignment of pointers returned > > >from palloc(). > > > > > Does this imply that more memory will be used that strictly necesary under > > linux? > > > > With regards from Maurice. > > Actually, perhaps less memory, because malloc memory is not aligned on > double boundaries, but this is all still just conjecture. Ok, you've convinced me. Sheesh... Change the description to "nice performance boost and use less memory". ;-) -dg David Gould dg@illustra.com 510.628.3783 or 510.305.9468 Informix Software (No, really) 300 Lakeside Drive Oakland, CA 94612 - I realize now that irony has no place in business communications.