1

I was profiling a c++ application using valgrind. In the leak summary, the number of errors is different from the number of contexts. What do contexts mean?

`ERROR SUMMARY: 44911 errors from 1070 contexts (suppressed: 0 from 0)`

Why are the number of errors different from the number of contexts in this case?

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
hAcKnRoCk
  • 1,118
  • 3
  • 16
  • 30

2 Answers2

2

context referes to the call stacks that lead to an error. To put it simple: that many places in the code cause errors.

rpy
  • 3,953
  • 2
  • 20
  • 31
  • ok. That is right. Then, any idea what do the number of errors mean? – hAcKnRoCk Mar 19 '16 at 21:14
  • If a error location is being executed more than once you will have more than one error . Consider a case with just one error location that is being executed 10 time you would have "10 errors from 1 contexts" – rpy Mar 19 '16 at 21:22
1

This is the definition for context error:

the (...) context for the error is the chain of function calls that led (or may led) to an error.

Look at this example in the Error Summary: This is the Error Summary

and here are the two error contexts: Two invalid write of size 1

So, to answer you question, the number of context refers to the number of functions in where problems are detected.

In the above example, you should read each context error from the bottom-up, and you can identify that both context errors are happening in the strconk file, in the 100 and 102 lines.

Please, also notice that for each context error, in the Address section, it shows a description of where that error is happening in memory, "0 bytes after a block of size 6". It is a good clue to identify exactly what is causing you troubles.

For detailed information on how Valdrind works, please refer to: https://valgrind.org/docs/manual/manual-core.html

Hope this helps you!

RicHincapie
  • 3,275
  • 1
  • 18
  • 30
  • What does it mean when I have 50 'contexts' but my log only shows, say, 45. So the last line is X errors in context 45 of 50. What happened to the last five? Last line is ERROR SUMMARY: xxx errors from 50 contexts (suppressed: 0 from 0) – JoeManiaci Nov 20 '20 at 19:17