ndakota
15-09-2011, 10:20
Ciao a tutti, da ieri sto usando valgrind come supporto per lo sviluppo di questo progetto universitario che sto facendo. Ora, sono riuscito ad eliminare tutti i memory leaks, tant'è che l'output finale di valgrind è questo
==5421== HEAP SUMMARY:
==5421== in use at exit: 0 bytes in 0 blocks
==5421== total heap usage: 422 allocs, 422 frees, 2,625 bytes allocated
==5421==
==5421== All heap blocks were freed -- no leaks are possible
Però a parte questo, mi segnala un sacco di errori che non so risolvere. Il programma ora come ora se lanciato normalmente sbaglia un output proprio per gli errori di memoria anche se non dà errori. Mentre se lanciato con valgrind perfino l'output è giusto.
Qualcuno mi sa dire a cosa sono dovuti errori di questo tipo
==5421== Conditional jump or move depends on uninitialised value(s)
==5421== at 0x804A1C6: graph_print (graph.c:44)
==5421== by 0x8048758: main (main.c:43)
==5421==
==5421== Invalid read of size 4
==5421== at 0x8049F14: list_publication_author (util.c:446)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a24c8 is 0 bytes inside a block of size 8 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x804936C: destroy_list (list.c:51)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 1
==5421== at 0x407BD6E: vfprintf (vfprintf.c:1620)
==5421== by 0x408389F: printf (printf.c:35)
==5421== by 0x8049F26: list_publication_author (util.c:446)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a2500 is 0 bytes inside a block of size 4 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x8049361: destroy_list (list.c:50)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 1
==5421== at 0x40A3128: _IO_file_xsputn@@GLIBC_2.1 (fileops.c:1317)
==5421== by 0x407BC65: vfprintf (vfprintf.c:1620)
==5421== by 0x408389F: printf (printf.c:35)
==5421== by 0x8049F26: list_publication_author (util.c:446)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a2502 is 2 bytes inside a block of size 4 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x8049361: destroy_list (list.c:50)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 1
==5421== at 0x40A313F: _IO_file_xsputn@@GLIBC_2.1 (fileops.c:1317)
==5421== by 0x407BC65: vfprintf (vfprintf.c:1620)
==5421== by 0x408389F: printf (printf.c:35)
==5421== by 0x8049F26: list_publication_author (util.c:446)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a2501 is 1 bytes inside a block of size 4 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x8049361: destroy_list (list.c:50)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 1
==5421== at 0x40A30B0: _IO_file_xsputn@@GLIBC_2.1 (fileops.c:1349)
==5421== by 0x407BC65: vfprintf (vfprintf.c:1620)
==5421== by 0x408389F: printf (printf.c:35)
==5421== by 0x8049F26: list_publication_author (util.c:446)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a2500 is 0 bytes inside a block of size 4 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x8049361: destroy_list (list.c:50)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 1
==5421== at 0x40A30BC: _IO_file_xsputn@@GLIBC_2.1 (fileops.c:1348)
==5421== by 0x407BC65: vfprintf (vfprintf.c:1620)
==5421== by 0x408389F: printf (printf.c:35)
==5421== by 0x8049F26: list_publication_author (util.c:446)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a2502 is 2 bytes inside a block of size 4 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x8049361: destroy_list (list.c:50)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 4
==5421== at 0x8049F2A: list_publication_author (util.c:448)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a24cc is 4 bytes inside a block of size 8 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x804936C: destroy_list (list.c:51)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 4
==5421== at 0x8049F4F: list_publication_author (util.c:453)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a24cc is 4 bytes inside a block of size 8 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x804936C: destroy_list (list.c:51)
==5421== by 0x8048796: main (main.c:47)
==5421==
Grazie a tutti :help:
==5421== HEAP SUMMARY:
==5421== in use at exit: 0 bytes in 0 blocks
==5421== total heap usage: 422 allocs, 422 frees, 2,625 bytes allocated
==5421==
==5421== All heap blocks were freed -- no leaks are possible
Però a parte questo, mi segnala un sacco di errori che non so risolvere. Il programma ora come ora se lanciato normalmente sbaglia un output proprio per gli errori di memoria anche se non dà errori. Mentre se lanciato con valgrind perfino l'output è giusto.
Qualcuno mi sa dire a cosa sono dovuti errori di questo tipo
==5421== Conditional jump or move depends on uninitialised value(s)
==5421== at 0x804A1C6: graph_print (graph.c:44)
==5421== by 0x8048758: main (main.c:43)
==5421==
==5421== Invalid read of size 4
==5421== at 0x8049F14: list_publication_author (util.c:446)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a24c8 is 0 bytes inside a block of size 8 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x804936C: destroy_list (list.c:51)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 1
==5421== at 0x407BD6E: vfprintf (vfprintf.c:1620)
==5421== by 0x408389F: printf (printf.c:35)
==5421== by 0x8049F26: list_publication_author (util.c:446)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a2500 is 0 bytes inside a block of size 4 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x8049361: destroy_list (list.c:50)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 1
==5421== at 0x40A3128: _IO_file_xsputn@@GLIBC_2.1 (fileops.c:1317)
==5421== by 0x407BC65: vfprintf (vfprintf.c:1620)
==5421== by 0x408389F: printf (printf.c:35)
==5421== by 0x8049F26: list_publication_author (util.c:446)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a2502 is 2 bytes inside a block of size 4 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x8049361: destroy_list (list.c:50)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 1
==5421== at 0x40A313F: _IO_file_xsputn@@GLIBC_2.1 (fileops.c:1317)
==5421== by 0x407BC65: vfprintf (vfprintf.c:1620)
==5421== by 0x408389F: printf (printf.c:35)
==5421== by 0x8049F26: list_publication_author (util.c:446)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a2501 is 1 bytes inside a block of size 4 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x8049361: destroy_list (list.c:50)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 1
==5421== at 0x40A30B0: _IO_file_xsputn@@GLIBC_2.1 (fileops.c:1349)
==5421== by 0x407BC65: vfprintf (vfprintf.c:1620)
==5421== by 0x408389F: printf (printf.c:35)
==5421== by 0x8049F26: list_publication_author (util.c:446)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a2500 is 0 bytes inside a block of size 4 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x8049361: destroy_list (list.c:50)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 1
==5421== at 0x40A30BC: _IO_file_xsputn@@GLIBC_2.1 (fileops.c:1348)
==5421== by 0x407BC65: vfprintf (vfprintf.c:1620)
==5421== by 0x408389F: printf (printf.c:35)
==5421== by 0x8049F26: list_publication_author (util.c:446)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a2502 is 2 bytes inside a block of size 4 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x8049361: destroy_list (list.c:50)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 4
==5421== at 0x8049F2A: list_publication_author (util.c:448)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a24cc is 4 bytes inside a block of size 8 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x804936C: destroy_list (list.c:51)
==5421== by 0x8048796: main (main.c:47)
==5421==
==5421== Invalid read of size 4
==5421== at 0x8049F4F: list_publication_author (util.c:453)
==5421== by 0x80487EA: main (main.c:55)
==5421== Address 0x41a24cc is 4 bytes inside a block of size 8 free'd
==5421== at 0x4025BF0: free (vg_replace_malloc.c:366)
==5421== by 0x804936C: destroy_list (list.c:51)
==5421== by 0x8048796: main (main.c:47)
==5421==
Grazie a tutti :help: