bug-gmp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading uninitialized memory


From: Andrew Vaught
Subject: Re: Reading uninitialized memory
Date: Sat, 26 Jan 2002 11:36:46 -0700 (MST)

On 25 Jan 2002, Torbjorn Granlund wrote:

> Andrew Vaught <address@hidden> writes:
> 
>   On 25 Jan 2002, Torbjorn Granlund wrote:
>   
>   > Andrew Vaught <address@hidden> writes:
>   > 
>   >      I'm guessing that zero is stored without limbs and that
>   >   mpz_get_si() always reads whatever passes for a non-limb.  The value
>   >   read from uninitialized memory is not used and doesn't affect the
>   >   value of zero, but you could get rid of a read and the spurious
>   >   error message from this and other bounds-checking programs.
>   > 
>   > Your analysis is correct.
>   
>      Here is a simple patch to avoid the problem:
>   
> I remain to be convinced that this problem should be patched in GMP.
> 
> It is an optimization to read memory speculatively, if we know it is
> from a valid address.  It would be better to fix the checker program
> to track undefined values and make sure they aren't actually used, or
> else live with their inaccuracies.

  In order for checker and similar products (purify, Electric Fence) to
prevent the propagation of undefined values, dataflow analysis at
compile-time is required.  The unused value from memory is read into a
register and then is sometimes not used.  Because checker is doing its
thing at run-time, it is too late for the dataflow analysis.

  From a scalar point of view, the speculative read is potentially
unnecessary.  If you're looking at it from a risc perspective, fetching
the limb could fill a delay slot, but then I'd worry about the order in
which the initializations are executed.  I don't know if C specifies an
order or not.

  Given the differing hardware that GMP supports, it seems to me that
different schemes will be faster on different machines.  Some machines
will overlap the read, others will just be slowed down by it.  Since this
not a core subroutine, I think that moving the read to avoid spurious
warnings is better.  Kevin's suggestion to initialize the limb for integer
zero is a viable alternative.

         Andy

-----------------                        XOLD(K,IC,I)=
Andy Vaught               ....        DO ITERS=1, 10  XOLD(K,IC,I)
address@hidden     |  |   /CALLMSOLVE(A,B,X,I,ITERS,TOL)+(RANNYU(0)
Arizona State University  ======|WRITE(6,'(I5,2X,F12.6)')ITERS,TOL -HALF)
Tempe, Arizona USA        OOOOOO \ENDDORETURN PARAMETER(ZERO=1.D0)*TENTH*DELTA






reply via email to

[Prev in Thread] Current Thread [Next in Thread]