解决随机崩溃 [英] Solving random crashes

查看:792
本文介绍了解决随机崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的C ++应用程序遇到随机崩溃,它可能不会崩溃一个月,然后在一小时内崩溃10次,有时它可能会崩溃,在启动时,有时它可能会崩溃,几个小时的操作(或



我在GNU / Linux和MingW在Windows上使用GCC,因此我不能使用Visual Studio JIT Debug ...



我不知道如何继续,看随机的代码不会工作,代码是巨大的(和好的部分不是我的工作,也有一些很好的旧的东西在它上面),我也没有如何重现崩溃的线索。



编辑:很多人提到...我如何核心转储,minidump或任何dump?这是我第一次需要postmortem调试。



EDIT2:实际上,DrMingw捕获了一个调用堆栈,没有内存信息...不幸的是,调用堆栈没有帮助我很多,因为接近结束突然它进入一些库(或某物),我没有调试信息,只得到一些十六进制数...所以我仍然需要一些体面的转储,提供更多的信息(特别是关于什么



此外,我的应用程序使用Lua和Luabind,也许是错误

解决方案

尝试 Valgrind (免费,开源):


Valgrind目前的分配
包括六个生产质量工具:
a内存错误检测器,两个线程
错误检测器,缓存和
分支预测分析器,
调用图生成缓存分析器,
和一个堆分析器。它还包括
两个实验工具:a
堆/堆栈/全局数组溢出
检测器和SimPoint基本块
向量生成器。它运行在
以下平台上:X86 / Linux,
AMD64 / Linux,PPC32 / Linux,PPC64 / Linux,
和X86 / Darwin(Mac OS X)。

b $ b

Valgrind常见问题



程序包中的Memcheck 部分可能是开始的地方:


Memcheck是一个内存错误检测器。
它可以检测在C和C ++程序中常见的以下问题




  • 你不应该,例如溢出和溢出堆
    阻塞,超过
    堆栈的顶部,并在
    已被释放后访问内存。


  • p>使用未定义的值,即尚未初始化的值或
    从其他
    未定义的值派生。


  • 错误释放堆内存,例如双重释放堆块,或
    不匹配使用malloc / new / new []
    与free / delete / delete []


  • 在memcpy和相关函数中重叠src和dst指针。


  • 内存泄漏。




I am getting random crashes on my C++ application, it may not crash for a month, and then crash 10 times in a hour, and sometimes it may crash on launch, while sometimes it may crash after several hours of operation (or not crash at all).

I use GCC on GNU/Linux and MingW on Windows, thus I can't use the Visual Studio JIT Debug...

I have no idea on how to proceed, looking randomly on the code would not work, the code is HUGE (and good part was not my work, also it has some good amount of legacy stuff on it), and I also don't have a clue on how to reproduce the crash.

EDIT: Lots of people mentioned that... how I make a core dump, minidump or whateverdump? This is the first time I need postmortem debugging.

EDIT2: Actually, DrMingw captured a call stack, no memory info... Unfortunately, the call stack don't helped me much, because near the end suddenly it go into some library (or something) that I don't have debug info, resulting only into some hexadecimal numbers... So I still need some decent dump that give more information (specially about what was in the memory... specifically, what was in the place that gave the "access violation" error)

Also, my application use Lua and Luabind, maybe the error is being caused by a .lua script, but I have no idea on how to debug that.

解决方案

Try Valgrind (it's free, open-source):

The Valgrind distribution currently includes six production-quality tools: a memory error detector, two thread error detectors, a cache and branch-prediction profiler, a call-graph generating cache profiler, and a heap profiler. It also includes two experimental tools: a heap/stack/global array overrun detector, and a SimPoint basic block vector generator. It runs on the following platforms: X86/Linux, AMD64/Linux, PPC32/Linux, PPC64/Linux, and X86/Darwin (Mac OS X).

Valgrind Frequently Asked Questions

The Memcheck part of the package is probably the place to start:

Memcheck is a memory error detector. It can detect the following problems that are common in C and C++ programs.

  • Accessing memory you shouldn't, e.g. overrunning and underrunning heap blocks, overrunning the top of the stack, and accessing memory after it has been freed.

  • Using undefined values, i.e. values that have not been initialised, or that have been derived from other undefined values.

  • Incorrect freeing of heap memory, such as double-freeing heap blocks, or mismatched use of malloc/new/new[] versus free/delete/delete[]

  • Overlapping src and dst pointers in memcpy and related functions.

  • Memory leaks.

这篇关于解决随机崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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