程序只崩溃作为发布构建 - 如何调试? [英] Program only crashes as release build -- how to debug?

查看:234
本文介绍了程序只崩溃作为发布构建 - 如何调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Schroedinger's Cat类型的问题 - 我的程序(实际上是我的程序的测试套件,但程序仍然是)崩溃,但只有当内置在释放模式,并且只有当从命令行。通过穴居人调试(即,令人讨厌的printf()消息遍布整个地方),我已经确定测试方法在代码崩溃,虽然不幸的是实际崩溃似乎发生在一些析构函数,因为我看到的最后一个跟踪消息是

I've got a "Schroedinger's Cat" type of problem here -- my program (actually the test suite for my program, but a program nonetheless) is crashing, but only when built in release mode, and only when launched from the command line. Through caveman debugging (ie, nasty printf() messages all over the place), I have determined the test method where the code is crashing, though unfortunately the actual crash seems to happen in some destructor, since the last trace messages I see are in other destructors which execute cleanly.

当我尝试在Visual Studio中运行此程序时,它不会崩溃。从WinDbg.exe启动时也一样。崩溃只发生在从命令行启动时。这是发生在Windows Vista,btw,不幸的是,我现在没有访问一台XP机器测试。

When I attempt to run this program inside of Visual Studio, it doesn't crash. Same goes when launching from WinDbg.exe. The crash only occurs when launching from the command line. This is happening under Windows Vista, btw, and unfortunately I don't have access to an XP machine right now to test on.

这将是非常好,如果我可以让Windows打印出一个堆栈跟踪,或者某事而不仅仅是终止程序,就像它已经干净地退出。有没有人有任何建议,如何我可以得到一些更有意义的信息在这里,并希望修复这个错误?

It would be really nice if I could get Windows to print out a stack trace, or something other than simply terminating the program as if it had exited cleanly. Does anyone have any advice as to how I could get some more meaningful information here and hopefully fix this bug?

编辑:问题的确是由一个out- bounds array,我在本文中更多地描述< a>。感谢大家在寻找这个问题方面的帮助!

The problem was indeed caused by an out-of-bounds array, which I describe more in this post. Thanks everybody for your help in finding this problem!

推荐答案

在我看过或听过的100% C或C ++程序在调试器中运行良好,但在外部运行时失败,原因是写入超过了函数局部数组的末尾。 (调试器放在堆栈上,所以你不太可能覆盖重要的东西。)

In 100% of the cases I've seen or heard of, where a C or C++ program runs fine in the debugger but fails when run outside, the cause has been writing past the end of a function local array. (The debugger puts more on the stack, so you're less likely to overwrite something important.)

这篇关于程序只崩溃作为发布构建 - 如何调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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