gpt4 book ai didi

c++ - 运行时错误检查/RTC

转载 作者:太空宇宙 更新时间:2023-11-04 14:23:24 26 4
gpt4 key购买 nike

我在我的应用程序中启用了/RTCs 来检测堆栈损坏问题。该应用程序有许多组件(dll),总 LOC 约为 40K。它有很多线程。

最初我在执行 18000 个周期后遇到崩溃。但是在启用/RTCs 选项后,我在 100 个周期内得到了 carsh。崩溃总是发生在一个名为 Reciever Thread 的线程中。但它始终在 3 或 4 个位置崩溃。当崩溃发生时,在某些情况下几乎所有局部变量看起来都已损坏。但我无法确定根本原因,因为我看不到崩溃发生点周围的任何问题。

我可以做些什么来缩小堆栈损坏的范围?
代码中有try catch语句,会不会妨碍查明原因?

请帮帮我

谢谢!

最佳答案

编辑:你在使用优化吗:

If you compile your program at the command line using any of the /RTC compiler options, any pragma optimize instructions in your code will silently fail. This is because run-time error checks are not valid in a release (optimized) build.

You should use /RTC for development builds; /RTC should not be used for a retail build. /RTC cannot be used with compiler optimizations (/O Options (Optimize Code)). A program image built with /RTC will be slightly larger and slightly slower than an image built with /Od (up to 5 percent slower than an /Od build).

如果您不发布任何代码,我只能推荐通用工具。

我在 Linux 上使用 valgrind --tool=helgrind 来做这种事,但我从你的问题中猜测你是在 Windows 上。

您可能会发现这个问题的答案很有用:Is there a good Valgrind substitute for Windows?

(如果您在遇到问题的地方发布代码或指出您使用了哪些方法来保护似乎已损坏的变量(互斥锁等...)可能会有所帮助)

关于c++ - 运行时错误检查/RTC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5912188/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com