Exe在调试中正常运行并在发布时崩溃 [英] Exe runs properly in debug and crash in release

查看:124
本文介绍了Exe在调试中正常运行并在发布时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我正在解决调试exe运行正常并且在发布时崩溃的问题。我在发布模式下调试exe并得到以下内容。

首先我给你看代码:

Hi friends,

I am fetching a problem in which debug exe is runs properly and in release it crashed. I debug the exe in release mode and got the following things.
First I show you code:

void CPlaybackThread::_GetGraphicSurface(uint64_t        in_ui64Time,
                                         TAPIMvSurface & out_rjSurface, int iLogoIndex)
{
	HRESULT		 hr				= MV_E_FAIL;
	unsigned long	 ulCount			= 1;
	double		 dStreamTime			= 0;
	uint64_t	 ui64PlayStreamTime		= 0;
	uint64_t	 ui64MgfFrameCount		= 0;
	TAPIMvFlexReader pJMgfPlayListReader	        = NULL;
	TAPIMvPlayList	 pJMGFPlayList			= NULL;
	TAPIMvSurface    pJLastReadMgfFrame		= NULL; 
	TAPIMvAVContent  pJLastReadMgfFrameSynch        = NULL; 
	TAPIMvSurface    pJReadMgfFrame			= NULL; 

	SMvSurfaceDescription sGraphicDesc = {sizeof(SMvSurfaceDescription)};
	CPlaybackContext &playbackContext = m_pPlaybackDlg->GetPlaybackContext (m_ulCurrentReaderIndex);

	ui64PlayStreamTime	= playbackContext.GetPlayStreamTime();
	pJMGFPlayList		= playbackContext.GetMGFPlaylist(iLogoIndex);
	pJMgfPlayListReader	= playbackContext.GetMGFReader(iLogoIndex);
	ui64MgfFrameCount	= pJMGFPlayList->GetDuration();
	
   if (ui64PlayStreamTime < ui64MgfFrameCount)
   {   
		hr = pJMgfPlayListReader -> GetBuffer (&pJReadMgfFrame, &ulCount, NULL, NULL, NULL, NULL, NULL, &dStreamTime, in_ui64Time, true);
		ASSERT(SUCCEEDED(hr));
   }

   if (SUCCEEDED(hr))
   {
      if (pJLastReadMgfFrame != NULL)
      {
         hr = pJLastReadMgfFrameSynch->SignalReadCompletion();
         ASSERT(SUCCEEDED(hr));

         pJLastReadMgfFrame      = NULL;
         pJLastReadMgfFrameSynch = NULL;
      }

      if (ulCount == 1 || ulCount == 2)
      {
		  out_rjSurface = pJReadMgfFrame;

         // We have the buffer.  Release the old one
         if (pJLastReadMgfFrame != NULL)
         {
            hr = pJLastReadMgfFrameSynch->SignalReadCompletion();
            ASSERT(SUCCEEDED(hr));

            pJLastReadMgfFrame      = NULL;
            pJLastReadMgfFrameSynch = NULL;
         }

         hr = out_rjSurface->GetSurfaceDescription(&sGraphicDesc);
         ASSERT(SUCCEEDED(hr));
		 
         hr = out_rjSurface->ChangeDestinationPosition(&sPosition[iLogoIndex]);
         ASSERT(SUCCEEDED(hr));

         return;
      }
   }
}





在上面的代码中,变量''pJLastReadMgfFrame''是最初为null,但是在发布中进行调试而没有使用任何其他值初始化此变量时,我将此值设置为非null。

从中得到的值我得不到。在条件''if(pJLastReadMgfFrame!= NULL)''它进入并崩溃在语句''hr = pJLastReadMgfFrameSynch - > SignalReadCompletion();''



任何人都可以帮我解决这个问题。



In the above code the variable ''pJLastReadMgfFrame'' is initially null, but while debugging in release without initializing this variable with any other value I got this value as not null.
From where it gets the value i am not getting. And in condition ''if (pJLastReadMgfFrame != NULL)'' it enters and crashed on statement ''hr = pJLastReadMgfFrameSynch -> SignalReadCompletion ();''

Can any body help me to resolve this problem.

推荐答案

内存由于程序中的另一个例程,可能已损坏。查看在调用_GetGraphicSurface()之前执行的代码。
Memory may be corrupt due to another routine in your program. Look at code that is executed before _GetGraphicSurface() is invoked.






也许你应该用警告编译你的项目等级/ W3至少。



我的经验是更高的警告级别,当然消除

这些警告会给你一个更稳定的exe即使是发布版本。



祝你好运
Hi,

perhaps you should compile your project with warning level /W3 at least.

My experience is that a higher warning level and of course the elimination
of these warnings will give you a more stable exe even as release version.

Best regards


查看堆栈是否被覆盖的简单方法,移动这些变量将这些神秘的值置于jMPGFPlaylist变量的声明之上,并查看是否覆盖了下一个值。
A simple way to see if the stack is being overwritten, move these variables that get these mysterious values above the declaration of jMPGFPlaylist variable and see if the next value is overwritten.


这篇关于Exe在调试中正常运行并在发布时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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