简体   繁体   English

valgrind 泄漏摘要中的上下文数量是指什么?

[英]What do the number of contexts in valgrind leak summary refer to?

I was profiling a c++ application using valgrind.我正在使用 valgrind 分析 C++ 应用程序。 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?在这种情况下,为什么错误数量与上下文数量不同?

context referes to the call stacks that lead to an error.上下文是指导致错误的调用堆栈。 To put it simple: that many places in the code cause errors.简单来说:代码中的很多地方都会导致错误。

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:在错误摘要中查看此示例: 这是错误摘要

and here are the two error contexts:这是两个错误上下文: 大小为 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.在上面的示例中,您应该自下而上读取每个上下文错误,并且您可以在strconk文件的 100 和 102 行中识别出两个上下文错误都发生了。

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".另请注意,对于每个上下文错误,在地址部分,它显示了该错误在内存中发生的位置的描述,“大小为 6 的块之后的 0 个字节”。 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有关 Valdrind 工作原理的详细信息,请参阅: https ://valgrind.org/docs/manual/manual-core.html

Hope this helps you!希望这对你有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM