-1

I'm using the command:

valgrind --tool=memcheck --leak-check=yes ./prog

When this runs with a test script, I get no inline error messages or warnings, I just get a Heap Summary and a leak summary.

Am I missing a flag or something?

==31420== HEAP SUMMARY:
==31420==     in use at exit: 1,580 bytes in 10 blocks
==31420==   total heap usage: 47 allocs, 37 frees, 7,132 bytes allocated
==31420== 
==31420== 1,580 (1,440 direct, 140 indirect) bytes in 5 blocks are definitely lost in loss record 2 of 2
==31420==    at 0x4C274A8: malloc (vg_replace_malloc.c:236)
==31420==    by 0x400FD4: main (lab1.c:51)
==31420== 
==31420== LEAK SUMMARY:
==31420==    definitely lost: 1,440 bytes in 5 blocks
==31420==    indirectly lost: 140 bytes in 5 blocks
==31420==      possibly lost: 0 bytes in 0 blocks
==31420==    still reachable: 0 bytes in 0 blocks
==31420==         suppressed: 0 bytes in 0 blocks
==31420== 
==31420== For counts of detected and suppressed errors, rerun with: -v
==31420== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)

The last time I used valgrind (a few days ago) it would print out error messages as they occurred, in addition to the heap and leak summaries.

EDIT: I tried leak-check=full, same result

The line mentioned in the heap summary (lab1.c:51) is:

        temp_record = malloc(sizeof(struct server_record));

And I use this pointer pretty often in my code. That is what was so helpful about the valgrind error messages before, they would show me when I would lose my pointer to this malloc or other problems.

Joshua Soileau
  • 2,933
  • 9
  • 40
  • 51
  • Thanks for the reply. I tried that as well, same output. – Joshua Soileau Jan 21 '12 at 18:39
  • and what do you expect? if you have no memory errors, you have no errors. From what I see, there is only a memory leak in lab1.c on line 51. –  Jan 21 '12 at 18:45
  • Yea, I see that as well. But that is a summary of all the blocks lost, usually I thought valgrind printed errors every time there was info lost, as it happened, outside the summary. I am having the same issue this person here had: http://stackoverflow.com/questions/7797864/how-do-you-get-valgrind-to-show-line-errors, but his issue was that he placed the leak-check flag after the program name, and I haven't done that. – Joshua Soileau Jan 21 '12 at 18:49
  • Josh, your questions is exact duplicate of that. You should have at least shown some code and expected output. Otherwise it doesn't make any sense. –  Jan 21 '12 at 18:56
  • I'm sorry. I didn't want to show so much code at once and clutter everyone's mind at once. If I need to give any more information, please let me know. – Joshua Soileau Jan 21 '12 at 19:11
  • Oh my god.. You don't need to paste the whole project. A minimal example reproducing the error (or what you think is the error) and explaining what do you expect is enough. I still do not get what do you want Valgrind to show you. It did clearly showed you a location where the memory is leaking. –  Jan 21 '12 at 19:16
  • I don't know what the error is, because valgrind won't post an error message. The location it pointed to is just the location that the leaked memory was created, not where it leaked. – Joshua Soileau Jan 21 '12 at 19:21

0 Answers0