Thread

  1. Re: [HACKERS] Re: Buffer overruns with the Electric Fence debugging library (Solved?)

    Maurice Gittens <mgittens@gits.nl> — 1998-03-20T18:30:55Z

    Ok,
    
    I think I've found the problem.
    The problem as I've identified it, seems to be a result of the fact that
    pointers returned by palloc are not alligned in accordance with
    the DOUBLEALIGN macro.
    
    The function ComputeDataSize returns a tuple size
    computed using an initial data size of 0 bytes. (which is
    double aligned according to the DOUBLEALIGN macro).
    This needless to say, makes sense.
    
    However the function DataFill is called with an expression similar to:
    
    DataFill((char *)tuple + tuple->t_hoff, ...) ;
    
    So it happens that the address for tuple data passed to the function
    DataFill,
    is not double aligned in the general case.
    So every now and then (when the tuple data pointer is not double aligned)
    the DataFill function actually uses memory more than it should,
    because the alignment macros bump the data pointer while no corresponding
    space has been reserved by the function ComputeDataSize.
    
    I think the source of the problem lies in the fact that palloc does not
    return memory addresses which are double aligned.
    
    I don't know how to solve the problem of making palloc return
     MAXALIGNED addresses in a _portable_ (compiler, os, cpu ) way.
    
    Can any one confirm this analyses and maybe give suggestions for a
    portable solution?
    
    With regards from Maurice.