[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Reading uninitialized memory
From: |
Andrew Vaught |
Subject: |
Reading uninitialized memory |
Date: |
Thu, 24 Jan 2002 23:42:45 -0700 (MST) |
Consider the following code:
#include <gmp.h>
int main(void) {
int m, k;
mpz_t n;
mpz_init(n);
mpz_set_si(n, 0);
k = mpz_get_si(n);
mpz_clear(n);
return 0;
}
When I run it under checkergcc, I get:
>From Checker (pid:06275): (ruh) read uninitialized byte(s) in a block.
When Reading 4 byte(s) at address 0x0805e850, inside the heap (sbrk).
0 byte(s) into a block (start: 0x805e850, length: 4, mdesc: 0x0).
The block was allocated from:
pc=0x080558a9 in chkr_malloc at stubs-malloc.c:57
pc=0x08048ed5 in __gmp_default_allocate at memory.c:50
pc=0x08048c27 in __gmpz_init at init.c:29
pc=0x08048685 in main at tst.c:8
pc=0x0805594f in this_main at stubs-main.c:13
pc=0x4002ea42 in checker_text_stubs_end at stubs/end-stubs.c:7
pc=0x080485c8 in *unknown* at *unknown*:0
Stack frames are:
pc=0x080489f5 in __gmpz_get_si at get_si.c:29
pc=0x08048724 in main at tst.c:11
pc=0x0805594f in this_main at stubs-main.c:13
pc=0x4002ea42 in checker_text_stubs_end at stubs/end-stubs.c:7
pc=0x080485c8 in *unknown* at *unknown*:0
Initialisation of detector...
Searching in data
Searching in stack
Searching in registers
>From Checker (pid:06275): (gar) garbage detector results.
There are no leaks.
Initialisation of detector...
Searching in data
Searching in stack
Searching in registers
>From Checker (pid:06275): (gar) garbage detector results.
There are no leaks.
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.
Cheers,
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
- Reading uninitialized memory,
Andrew Vaught <=
- Re: Reading uninitialized memory, Torbjorn Granlund, 2002/01/25
- Re: Reading uninitialized memory, Andrew Vaught, 2002/01/25
- Re: Reading uninitialized memory, Torbjorn Granlund, 2002/01/25
- Re: Reading uninitialized memory, Kevin Ryde, 2002/01/25
- Re: Reading uninitialized memory, Andrew Vaught, 2002/01/26
- Re: Reading uninitialized memory, Kevin Ryde, 2002/01/26
- Re: Reading uninitialized memory, Andrew Vaught, 2002/01/26
- Re: Reading uninitialized memory, Torbjorn Granlund, 2002/01/26
- Re: Reading uninitialized memory, Kevin Ryde, 2002/01/26
- Re: Reading uninitialized memory, Andrew Vaught, 2002/01/26