On Mon, Oct 08, 2007 at 09:16:49AM -0300, Diego Sisto wrote:
> Buenos dias, tengo el siguiente problema. Tengo un programa en c que trabaja
> con memoria dinámica (aclaro por si da pistas) que me tira un segmentation
> fault en la última linea. El valgrind dice lo siguiente:
> 
> ==14094== Use of uninitialised value of size 4
> ==14094==    at 0x8048A70: main (main.c:127)

Estas usando un valor que no inicializaste. O sea, algo asi:

        int i;
        printf("%d\n", i);


> ==14094== Jump to the invalid address stated on the next line
> ==14094==    at 0x0: ???
> ==14094==    by 0x80485A0: (within /home/diego/workspace/ej2/src/ej2)
> ==14094==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

Estas haciendo un jump a NULL (que es el 0x0), como te dice ahi. Para
saber bien que estas haciendo deberias compilar tu aplicación con
simbolos de debugging y volver a correr el valgrind. Ahi, te va a decir
el archivo y número de línea donde estas haciendo esto.

Me explico?


> ==14094== Process terminating with default action of signal 11 (SIGSEGV)
> ==14094==  Bad permissions for mapped region at address 0x0
> ==14094==    at 0x0: ???
> ==14094==    by 0x80485A0: (within /home/diego/workspace/ej2/src/ej2)

Hiciste un jump a NULL, y esto es una consecuencia de eso: como "no
tenes permisos" para saltar a NULL, el kernel termino tu proceso con la
señal de segmentation fault.


> Also, for leak reports involving shared objects, if the shared object is
> unloaded before the program terminates, Valgrind will discard the debug
> information and the error message will be full of ??? entries. The
> workaround here is to avoid calling dlclose() on these shared objects.

No tiene nada que ver en este caso. Usar shared objects implica usar
bibliotecas dinamicas cargadas en runtime con dlopen() o algo
equivalente, y ademas en este caso los ??? no son por esto sino por tu
salto a NULL.

Espero que te sirva!

Gracias,
                Alberto

_______________________________________________
Lista de correo Programacion.
[email protected]
http://listas.fi.uba.ar/mailman/listinfo/programacion

Responder a