RELEASE配置中的MS Visual Studio 2005中的代码崩溃

时间:2021-11-07 01:32:45

I have a workspace for running an H.263 Video Encoder in a loop for 31 times i.e. the main is executed 31 times to generate 31 different encoded bit streams. This MS Visual Studio 2005 Workspace has all C source files. When i create a "DEBUG" configuration for the workspace and build and execute it, it runs fine, i.e. it generates all the 31 output files as expected. But when I set the configuration of the workspace to "RELEASE" mdoe, and repeat the process, the encoder crashes at some test case run.

我有一个工作空间用于循环运行H.263视频编码器31次,即主要执行31次以生成31个不同的编码比特流。此MS Visual Studio 2005工作区包含所有C源文件。当我为工作区创建“DEBUG”配置并构建并执行它时,它运行正常,即它按预期生成所有31个输出文件。但是当我将工作区的配置设置为“RELEASE”mdoe并重复该过程时,编码器在某些测试用例运行时崩溃。

Now to debug this is verified following:

现在调试这个验证如下:

  1. Analyzed the code to see if there was any variable initialization being missed out in every run of the encoder
  2. 分析代码以查看在编码器的每次运行中是否遗漏了任何变量初始化

  3. Checked the various Workspace(Solution) options in both the modes (DEBUG and RELEASE).
  4. 检查两种模式(DEBUG和RELEASE)中的各种工作区(解决方案)选项。

There are some obvious differences, but i turned the optimization related options explicitly same in both modes.

有一些明显的差异,但我在两种模式中明确地将优化相关选项相同。

But still could not nail the problem and find a fix for that. Any pointers?

但仍然无法解决问题并找到解决方案。有什么指针吗?

-Ajit.

8 个解决方案

#1


2  

It's hard to say what the problem might be without carefully inspecting the code. However...

如果不仔细检查代码,很难说出问题可能是什么。然而...

One of the differences between debug and release builds is how the function call stack frame is set up. There are certain classes of bad things you can do (like calling a function with the wrong number of arguments) that are not fatal in a debug build but crash horribly in a release build. Perhaps you could try changing the stack frame related options (I forget what they're called, sorry) in the release build to the same as the debug build and see whether that helps.

调试和发布版本之间的区别之一是如何设置函数调用堆栈帧。您可以执行某些类别的坏事(比如调用具有错误数量的参数的函数),这些类在调试版本中不是致命的,但在发布版本中可怕地崩溃。也许您可以尝试在发布版本中尝试更改与堆栈框架相关的选项(我忘了他们被称为对不起),与调试版本相同,看看是否有帮助。

Another thing might be to enable all the warnings you possibly can, and fix them all.

另一件事可能是启用所有可能的警告,并将其全部修复。

#2


1  

Could be a concurrency problem of two threads. The DEBUG configuration slows the execution down, so the problem does not occur. But, only a guess.

可能是两个线程的并发问题。 DEBUG配置会降低执行速度,因此不会出现问题。但是,只有一个猜测。

#3


1  

Interesting problem.. Are you sure you have no conditional compilation code lurking around that is not being compiled in release mode? i.e:

有趣的问题..你确定没有潜伏的条件编译代码没有在发布模式下编译吗?即:

#if (DEBUG)
// Debug Code here
#else
// Release Code here
#endif

Thats the only thing I can really think of.. Never experienced anything like this myself..

这是我唯一能想到的东西..从来没有经历过这样的事情。

#4


1  

Can you add the debug symbols to the release build and run it in the debugger to see where and why it crashed?

您是否可以将调试符号添加到发布版本中并在调试器中运行它以查看它崩溃的位置和原因?

#5


1  

Yeah, those bastard crashes are the hardest to fix. Fortunatly, there are some steps you can do that will give you clues before you resort to manually looking at the code and hope to find the needle.

是的,那些混蛋崩溃是最难修复的。幸运的是,您可以采取一些步骤,在您手动查看代码并希望找到针头之前,这些步骤可以为您提供线索。

When does it crash? At every test? At a specific test? What does that test does that the others don't?

什么时候崩溃?每次测试?在特定的测试?那个测试做的是什么,其他人没有?

What's the error? If it's an access violation, is there a pattern to where it happens? If the addresses are low, it might mean there is an uninitialised pointer somewhere.

什么是错误?如果是访问冲突,是否有模式发生?如果地址较低,则可能意味着某处存在未初始化的指针。

Is the program crashing with Debug configuration but without the debugger attached? If so, it's most likely a thread synchronisation problem as John Smithers pointed out.

程序是否因为调试配置而崩溃但未附加调试器?如果是这样,它很可能是John Smithers指出的线程同步问题。

Have you tried running the code through an analyser such as Purify? It's slow but it's usually worth the wait.

您是否尝试通过Purify等分析器运行代码?它很慢但通常值得等待。

Try to debug the release configuration anyway. It will only dump assemblies but it can still give you an indication of what happens such as if the code pointer jumps in the middle of garbage or hits a breakpoint in an external library.

尽量尝试调试发布配置。它只会转储程序集,但它仍然可以指示发生了什么,例如代码指针是在垃圾中间跳转还是在外部库中遇到断点。

Are you on an Intel architecture? If not, watch for memory alignement errors, they hard crash without warning on some architectures and those codec algorithm tend to create those situations a lot since they are overly optimized.

您是英特尔架构吗?如果没有,请注意内存对齐错误,它们在某些体系结构上没有警告就会崩溃,而那些编解码器算法往往会因为过度优化而大量创建这些情况。

#6


0  

Are you sure there are no precompile directives that, say, ignores some really important code in Release mode but allows them in Debug?

你确定没有预编译指令,比如说,在发布模式下忽略了一些非常重要的代码但在Debug中允许它们吗?

Also, have you implemented any logging that might point out to the precise assembly that's throwing the error?

此外,您是否实现了任何可能指向抛出错误的精确程序集的日志记录?

#7


0  

I would look at the crash in more detail - if it's crashing in a test case, then it sounds pretty easily reproducible, which is usually most of the challenge.

我会更详细地看一下崩溃 - 如果它在测试用例中崩溃,那么听起来很容易重现,这通常是大部分的挑战。

#8


0  

Another thing to consider: in debug mode, the variables are initialized with 0xCCCCCCCC instead of zero. That might have some nasty side effects.

另一件需要考虑的事情是:在调试模式下,变量初始化为0xCCCCCCCC而不是零。这可能会产生一些令人讨厌的副作用。

#1


2  

It's hard to say what the problem might be without carefully inspecting the code. However...

如果不仔细检查代码,很难说出问题可能是什么。然而...

One of the differences between debug and release builds is how the function call stack frame is set up. There are certain classes of bad things you can do (like calling a function with the wrong number of arguments) that are not fatal in a debug build but crash horribly in a release build. Perhaps you could try changing the stack frame related options (I forget what they're called, sorry) in the release build to the same as the debug build and see whether that helps.

调试和发布版本之间的区别之一是如何设置函数调用堆栈帧。您可以执行某些类别的坏事(比如调用具有错误数量的参数的函数),这些类在调试版本中不是致命的,但在发布版本中可怕地崩溃。也许您可以尝试在发布版本中尝试更改与堆栈框架相关的选项(我忘了他们被称为对不起),与调试版本相同,看看是否有帮助。

Another thing might be to enable all the warnings you possibly can, and fix them all.

另一件事可能是启用所有可能的警告,并将其全部修复。

#2


1  

Could be a concurrency problem of two threads. The DEBUG configuration slows the execution down, so the problem does not occur. But, only a guess.

可能是两个线程的并发问题。 DEBUG配置会降低执行速度,因此不会出现问题。但是,只有一个猜测。

#3


1  

Interesting problem.. Are you sure you have no conditional compilation code lurking around that is not being compiled in release mode? i.e:

有趣的问题..你确定没有潜伏的条件编译代码没有在发布模式下编译吗?即:

#if (DEBUG)
// Debug Code here
#else
// Release Code here
#endif

Thats the only thing I can really think of.. Never experienced anything like this myself..

这是我唯一能想到的东西..从来没有经历过这样的事情。

#4


1  

Can you add the debug symbols to the release build and run it in the debugger to see where and why it crashed?

您是否可以将调试符号添加到发布版本中并在调试器中运行它以查看它崩溃的位置和原因?

#5


1  

Yeah, those bastard crashes are the hardest to fix. Fortunatly, there are some steps you can do that will give you clues before you resort to manually looking at the code and hope to find the needle.

是的,那些混蛋崩溃是最难修复的。幸运的是,您可以采取一些步骤,在您手动查看代码并希望找到针头之前,这些步骤可以为您提供线索。

When does it crash? At every test? At a specific test? What does that test does that the others don't?

什么时候崩溃?每次测试?在特定的测试?那个测试做的是什么,其他人没有?

What's the error? If it's an access violation, is there a pattern to where it happens? If the addresses are low, it might mean there is an uninitialised pointer somewhere.

什么是错误?如果是访问冲突,是否有模式发生?如果地址较低,则可能意味着某处存在未初始化的指针。

Is the program crashing with Debug configuration but without the debugger attached? If so, it's most likely a thread synchronisation problem as John Smithers pointed out.

程序是否因为调试配置而崩溃但未附加调试器?如果是这样,它很可能是John Smithers指出的线程同步问题。

Have you tried running the code through an analyser such as Purify? It's slow but it's usually worth the wait.

您是否尝试通过Purify等分析器运行代码?它很慢但通常值得等待。

Try to debug the release configuration anyway. It will only dump assemblies but it can still give you an indication of what happens such as if the code pointer jumps in the middle of garbage or hits a breakpoint in an external library.

尽量尝试调试发布配置。它只会转储程序集,但它仍然可以指示发生了什么,例如代码指针是在垃圾中间跳转还是在外部库中遇到断点。

Are you on an Intel architecture? If not, watch for memory alignement errors, they hard crash without warning on some architectures and those codec algorithm tend to create those situations a lot since they are overly optimized.

您是英特尔架构吗?如果没有,请注意内存对齐错误,它们在某些体系结构上没有警告就会崩溃,而那些编解码器算法往往会因为过度优化而大量创建这些情况。

#6


0  

Are you sure there are no precompile directives that, say, ignores some really important code in Release mode but allows them in Debug?

你确定没有预编译指令,比如说,在发布模式下忽略了一些非常重要的代码但在Debug中允许它们吗?

Also, have you implemented any logging that might point out to the precise assembly that's throwing the error?

此外,您是否实现了任何可能指向抛出错误的精确程序集的日志记录?

#7


0  

I would look at the crash in more detail - if it's crashing in a test case, then it sounds pretty easily reproducible, which is usually most of the challenge.

我会更详细地看一下崩溃 - 如果它在测试用例中崩溃,那么听起来很容易重现,这通常是大部分的挑战。

#8


0  

Another thing to consider: in debug mode, the variables are initialized with 0xCCCCCCCC instead of zero. That might have some nasty side effects.

另一件需要考虑的事情是:在调试模式下,变量初始化为0xCCCCCCCC而不是零。这可能会产生一些令人讨厌的副作用。