Helgrind 在运行时停止程序
Helgrind stops program during runtime
Helgrind 在 运行 时间内冻结。必须应用 CTRL+C (SIGINT
) 才能退出 运行。
我编写了一个可以正确执行的程序,如果 运行 以通常的方式不使用 --tool=helgrind
,valgrind 不会报告任何程序。但是当使用 helgrind 时,程序会在 运行 时间内停止。
我还没有发现任何导致 helgrind 出现这种行为的典型问题。有什么建议吗?我也找不到使用 vgdb
的任何问题。
编辑: 该程序利用信号量和 pthreads。
编辑: 添加一堆 fprintf
输出使 helgrind 工作得很好。为什么呢?
找到答案。
使用信号量的值作为条件变量非常慢。因此,由于 sem_post/sem_wait 是原子操作并且 helgrind 具有 "slower check"(非原子),因此我的程序更新信号量的速度比 helgrind 重新检查信号量快。从而冻结了helgrind。所以线程计数器或其他类型的条件变量解决了这个问题。
Helgrind 在 运行 时间内冻结。必须应用 CTRL+C (SIGINT
) 才能退出 运行。
我编写了一个可以正确执行的程序,如果 运行 以通常的方式不使用 --tool=helgrind
,valgrind 不会报告任何程序。但是当使用 helgrind 时,程序会在 运行 时间内停止。
我还没有发现任何导致 helgrind 出现这种行为的典型问题。有什么建议吗?我也找不到使用 vgdb
的任何问题。
编辑: 该程序利用信号量和 pthreads。
编辑: 添加一堆 fprintf
输出使 helgrind 工作得很好。为什么呢?
找到答案。
使用信号量的值作为条件变量非常慢。因此,由于 sem_post/sem_wait 是原子操作并且 helgrind 具有 "slower check"(非原子),因此我的程序更新信号量的速度比 helgrind 重新检查信号量快。从而冻结了helgrind。所以线程计数器或其他类型的条件变量解决了这个问题。