Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1708 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  pb avec valgrind

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

pb avec valgrind

n°1535590
franceso
Posté le 29-03-2007 à 09:42:13  profilanswer
 

[:zytra] Salut,
 
je rencontre un problème bizarre avec valgrind : j'ai l'impression que l'exécution de mon binaire ne se passe pas de la même manière lorsque je le lance seul, ou avec valgrind.
 
Voici le bout de code incriminé:

Code :
  1. inline void addPoint (int i, int j, int k, Point p)
  2.     {
  3. #ifdef DEBUG
  4.       if (k<0 || k>=val.size()    ||
  5.           j<0 || j>=val[k].size() ||
  6.           i<0 || i>=val[k][j].size())
  7.         {
  8.           std::cerr << "i = " << i << "\t" << "size = " << val[k][j].size() << "\n" ;
  9.           std::cerr << "j = " << j << "\t" << "size = " << val[k].size()    << "\n" ;
  10.           std::cerr << "k = " << k << "\t" << "size = " << val.size()       << "\n" ;
  11.           assert (!"Indices out of bounds" );
  12.         }
  13. #endif
  14.       val[k][j][i] += 1;
  15.     }


 
Lorsque j'exécute tout seul, tout se passe bien (en particulier, le assert() n'est pas rencontré):

~/Hough/trunk> ./hough
0.285 0.205 0.76969


 
Mais avec valgrind, tout se passe différemment:

~/Hough/trunk> valgrind ./hough
==4776== Memcheck, a memory error detector.
==4776== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==4776== Using LibVEX rev 1367, a library for dynamic binary translation.
==4776== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
==4776== Using valgrind-3.0.1, a dynamic binary instrumentation framework.
==4776== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==4776== For more details, rerun with: -v
==4776==  
==4776== Conditional jump or move depends on uninitialised value(s)
==4776==    at 0x1B8F7B0F: index (in /lib/ld-2.4.so)
==4776==  
==4776== Conditional jump or move depends on uninitialised value(s)
==4776==    at 0x1B8F7B20: index (in /lib/ld-2.4.so)
i = 100 size = 100
j = 17  size = 200
k = 20  size = 100
hough: stdGrid.h:52: void stdGrid<Point, Position>::addPoint(int, int, int, Point) [with Point = stdPoint, Position = stdPosition]: Assertion `!"Indices out of bounds"' failed.
==4776==  
==4776== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 25 from 4)
==4776== malloc/free: in use at exit: 8241200 bytes in 20101 blocks.
==4776== malloc/free: 20306 allocs, 205 frees, 8324578 bytes allocated.
==4776== For counts of detected errors, rerun with: -v
==4776== searching for pointers to 20101 not-freed blocks.
==4776== checked 8376368 bytes.
==4776==  
==4776== LEAK SUMMARY:
==4776==    definitely lost: 0 bytes in 0 blocks.
==4776==      possibly lost: 0 bytes in 0 blocks.
==4776==    still reachable: 8241200 bytes in 20101 blocks.
==4776==         suppressed: 0 bytes in 0 blocks.
==4776== Reachable blocks (those to which a pointer was found) are not shown.
==4776== To see them, rerun with: --show-reachable=yes
zsh: abort      valgrind ./hough


 
Je suis pas du tout spécialiste de valgrind, mais ça ne me paraît quand même pas bien normal...


---------------
TriScale innov
mood
Publicité
Posté le 29-03-2007 à 09:42:13  profilanswer
 

n°1535880
franceso
Posté le 29-03-2007 à 15:36:31  profilanswer
 

:bounce: Petit up svp...
 
Y a pas d'utilisateurs de valgrind ici qui peuvent me dire s'ils ont déjà observé ce genre de comportement ?


---------------
TriScale innov
n°1535961
franceso
Posté le 29-03-2007 à 16:59:17  profilanswer
 

Je viens de trouver un bug qui faisait sortir mes indices des limites dans certains cas. Je n'ai maintenant plus de problème (mêmes résultats avec valgrind qu'avec un lancement direct), mais je me demande toujours pourquoi le bug n'apparaissait qu'avec valgrind...


---------------
TriScale innov

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  pb avec valgrind

 

Sujets relatifs
Scons et valgrind sont sur un bateau...Utilisation de valgrind : comprendre les messages
Plus de sujets relatifs à : pb avec valgrind


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR