2011-06-08 3 views
1

J'ai un peu de mal à comprendre la sortie Valgrind:sortie Valgrind confusion

1> « écriture non valide de la taille 4 » est à venir dans un fichier adb généré automatiquement,

return (gnat_exit_status); -- this is line 314 of b~main.adb 

et le gnat_exit_status est défini comme ceci:

gnat_exit_status : Integer; 
    pragma Import (C, gnat_exit_status); 

2> "se terminant processus avec l'action par défaut du signal 11 (SIGSEGV)" est-ce valgrind ou mon programme? Je reçois une valeur de retour de 139 à partir de valgrind, mais en cours d'exécution principal, je reçois 0, ce qui est ce que j'attends!

sortie pleine de memcheck:

$ valgrind ./main 
==2844== Memcheck, a memory error detector 
==2844== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. 
==2844== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info 
==2844== Command: ./main 
==2844== 
==2844== Invalid write of size 4 
==2844== at 0x804BA2F: main (b~main.adb:314) 
==2844== Address 0xbee56294 is not stack'd, malloc'd or (recently) free'd 
==2844== 
==2844== 
==2844== Process terminating with default action of signal 11 (SIGSEGV) 
==2844== Access not within mapped region at address 0xBEE56294 
==2844== at 0x804BA2F: main (b~main.adb:314) 
==2844== If you believe this happened as a result of a stack 
==2844== overflow in your program's main thread (unlikely but 
==2844== possible), you can try to increase the size of the 
==2844== main thread stack using the --main-stacksize= flag. 
==2844== The main thread stack size used in this run was 8388608. 
==2844== 
==2844== HEAP SUMMARY: 
==2844==  in use at exit: 0 bytes in 0 blocks 
==2844== total heap usage: 0 allocs, 0 frees, 0 bytes allocated 
==2844== 
==2844== All heap blocks were freed -- no leaks are possible 
==2844== 
==2844== For counts of detected and suppressed errors, rerun with: -v 
==2844== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 19 from 8) 
Segmentation fault 
$ 

Toute aide Apprécié :)

NWS

Répondre

2

Je ne l'ai pas utilisé Valgrind depuis le collège, mais il y a quelques choses que je peux vous donner à pointez-vous dans la bonne direction.

D'abord, je sais que la façon dont le prog est compilé fait la différence. Vous devriez utiliser l'option -g et NE PAS utiliser -O # (optimisation). De plus, j'ai toujours lancé Valgrind avec -v pour qu'il sorte le plus d'infos (beaucoup d'infos).

Consultez cette page: http://www.redhat.com/magazine/015jan06/features/valgrind/

combat à mi-chemin est vers le bas une section intitulée « Avant d'exécuter valgrind » et « Comment lire le rapport d'erreur valgrind » vous aidera.