简体   繁体   English

堆栈溢出后,Visual Studio 2008显示完整的堆栈跟踪

[英]Visual Studio 2008 show FULL stack trace after stack overflow

I have a running C++ project that has had a stack overflow whilst I was running it under the debugger within the IDE. 我有一个正在运行的C ++项目,当我在IDE中的调试器下运行该项目时,它发生了堆栈溢出。

Visual Studio 2008 has taken it upon itself to truncate the stack trace of the overflowing thread (well hey if we're gonna do that why check for overflows at all?). Visual Studio 2008自行截断了溢出线程的堆栈跟踪(好吧,如果我们要这样做,为什么还要检查是否有溢出?)。

Is there some view option or debugging option that will show me the root of this thread's calls? 是否有一些视图选项或调试选项可以向我显示此线程调用的根?

So in essence apart from offering me reasons why a stack trace can be corrupted etc (shall I disable my AV and run memtest86 as well?) does anyone have ACTUAL INFORMATION about the truncation of stack traces in Visual Studio 2008? 因此,从本质上讲,除了向我提供为什么会损坏堆栈跟踪的原因(我也应禁用我的AV并同时运行memtest86吗?),有人是否有关于Visual Studio 2008中截断堆栈跟踪的实际信息?

The simple solution is to keep your stack small enough from the start, so that the stack overflow happens earlier. 一种简单的解决方案是从一开始就使堆栈足够小,以便堆栈溢出更早发生。 You didn't want one megabtyte of repeated functions anyway. 无论如何,您都不想要一百万个重复功能。

If you want to have a big stack AND avoid stack overflow due to some simple recursion bug, use TLS: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686749(v=vs.85).aspx . 如果您希望拥有较大的堆栈并避免由于某些简单的递归错误而导致堆栈溢出,请使用TLS: http : //msdn.microsoft.com/zh-cn/library/windows/desktop/ms686749( v= vs.85) .aspx

Allocate one slot when the process starts and then increment the value of the slot using TlsGetValue and TlsSetValue and then check if it's exceeded, then break into the debugger or do some other "pause" in your supposedly faulty function. 在进程开始时分配一个插槽,然后使用TlsGetValue和TlsSetValue递增该插槽的值,然后检查是否超过了该插槽的值,然后闯入调试器,或者在您认为有问题的函数中执行其他“暂停”操作。

It won't work for 3rd party code without hacks, but it worked well for me to work around the limitation and also being pretty light. 没有黑客,它将无法用于第三方代码,但对我来说,克服限制并保持轻巧效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM