有硬实时跟踪内存损坏 - 用Valgrind的运行时,没有任何错误运行正常 [英] Having hard time tracking memory corruption - when running with Valgrind runs correctly with no errors

查看:378
本文介绍了有硬实时跟踪内存损坏 - 用Valgrind的运行时,没有任何错误运行正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个复杂的程序,是在重型输入(实际上任何输入),没有实现多线程运作良好。结果
我们已经实现了多线程与线程池,并给予这些输入参数,我得到这些结果:结果
注意:如果我说的没有任何错误,这意味着我已经与的valgrind -v 当我说没有内存泄漏,这意味着我已经与的valgrind --leak检查=全-v <测试它/ code>)。


  1. small_file: 1个多工(线程),没有错误Valgrind的成功运行,没有内存泄漏

  2. medium_file:有了它成功运行,没有错误/内存泄漏1工人。随着> 1的工人,我得到:一。通常堆损坏错误,B。双免费的。当的valgrind -v 与> 1工人运行程序成功完成。此外,没有错误的valgrind从印刷,也就是错误摘要:从0 0上下文错误(SUP pressed:2 2)<​​/ code>。

现在,我没有得到的valgrind下手任何错误,我能做些什么来找到这个复杂和大型应用程序的内存损坏问题?

DevelopmentEnvironment:结果
Ubuntu的,64位,gcc版本:4.7.2和4.8.1(不同的电脑,Ubuntu的的更新版本)


解决方案

  

使用> 1的工人,我得到:一。通常堆损坏错误,b.double免费。
  当Valgrind的运行-v用> 1工人程序成功完成


根据以上症状,在我看来,明确有某种同步问题在你的程序中发生的事情。它看起来像你的程序共享线程,因此每当有一些你所面对的问题数据的比赛。

之间的堆内存地址

您也提到,当你正在运行的valgrind -v,那么你的程序成功完成。这表明你的程序有同步问题,而且也依赖于序列/时间。这是最困难的错误找out.We应该还记得,直到程序去动态的工具,不会给任何警告,并执行一些错误之一。我的意思是有可能是在程序问题,但执行的顺序(因为有一些计时相关的问题)确定是否工具会捕捉那些失败或没有。

说了这么多,我觉得没有那种切的方式找到大programs.However这样的错误我强烈怀疑,有一些数据的赛车场景这是导致内存破坏/双免费。所以,你可能要使用 Helgrind 以检查/查找数据赛车/线程问题,这可能会导致内存损坏。

We have a complex program that is working well on heavy duty input (any input actually) with no multithreading implemented.
We've implemented multithreading with a threadpool, and given these input parameters I get these results:
(Note: Where I say no errors, it means I've tested with valgrind -v and when I say no memory leaks, it means I've tested it with valgrind --leak-check=full -v).

  1. small_file: Runs successfully with more than 1 workers (threads), no valgrind errors, no memory leaks
  2. medium_file: With 1 worker it runs successfully, no errors/memory leaks. With > 1 workers, I get: a. usually heap-corruption error, b. double-free. When running with valgrind -v with > 1 workers the program completes successfully. Also, no errors are printed from valgrind, that is ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2).

Now that I don't get any errors from valgrind to start with, what can I do to find the memory corruption problem in this complex and big application?

DevelopmentEnvironment:
Ubuntu, 64bit, gcc version: 4.7.2 and 4.8.1 (different computers, newer version of Ubuntu).

解决方案

With > 1 workers, I get: a. usually heap-corruption error, b.double-free. When running with valgrind -v with > 1 workers the program completes successfully

Based on the above symptoms, it looks to me that there is clearly some sort of synchronization problem is happening in your program. It looks like your program is sharing the heap memory address between the threads and hence whenever there is some data race you are facing problem.

You have also mentioned that when you are running valgrind -v, then your program is completing successfully. This indicates that your program has synchronization problem and that too is dependant on the sequence/timing. These are one of the most difficult bug to find out.We should also remember that dynamic tools would not give any warning until program goes and execute something wrong. I mean there could be problem in the program, but sequence of execution(as there is some timing related problem) determined whether tools would capture those failure or not.

Having said that, I think there is not sort cut way to find such bugs in big programs.However I strongly suspect that there is some data racing scenario which is leading to memory corruption/double free. So you may want to use Helgrind to check/find data racing/threading problem which might be leading to memory corruption.

这篇关于有硬实时跟踪内存损坏 - 用Valgrind的运行时,没有任何错误运行正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆