C++ 二进制文件在使用 valgrind 运行时完美执行,但单独运行此二进制文件时失败

标签 c++ valgrind

当我使用以下命令运行此二进制文件时,我有一个 C++ 可执行文件

valgrind -v --leak-check=full --show-reachable=yes --track-origins=yes mybinary -mode init > 5.log 2>&1

以0退出,生成所有输出文件。

但是当我像这样运行这个二进制文件时

mybinary -mode init > 5.log 2>&1

很多地方(一个接一个)都是核心倾销。

为什么当我运行 valgrind 时行为会改变? valgrind 是否设置任何内部环境变量?

最佳答案

作为非常 Valgrind 手册 says ,

Valgrind serialises execution so that only one (kernel) thread is running at a time. [...] your program will see very different scheduling when run on Valgrind than it does when running normally. This is both because Valgrind is serialising the threads, and because the code runs so much slower than normal.

此外,您正在运行默认的 Valgrind 工具 memcheck。您可以尝试使用任何以线程为中心的工具,例如 helgrind 或 DRD,以获取有关并发问题的具体信息。

关于C++ 二进制文件在使用 valgrind 运行时完美执行,但单独运行此二进制文件时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17468448/

相关文章:

c++ - Valgrind 在空析构函数上给出 "Invalid write of size 8"

c - helgrind 中的 libxml2 多线程错误

c++ - 即时创建和写入 vector

c++ - 按字母顺序排列的字符串数组排序

c++ - 无论如何有一个 valgrind 消息 "Conditional jump or move depends on uninitialized value"可以是所谓的 'false positive'

c - malloc'ing 和 realloc'ing 指针在返回时导致内存泄漏

debugging - 如何为 ARMv5 平台构建 Valgrind?

c++ - 不能包含 <QtCharts/QLineSeries>

C++ 霍夫曼代码头

c++ - 如何为 main.cpp 中的泛型类重载 operator>