Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
C++
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;
      }
   }
}


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.
Posted

Memory may be corrupt due to another routine in your program. Look at code that is executed before _GetGraphicSurface() is invoked.
 
Share this answer
 
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
 
Share this answer
 
Comments
H.Brydon 14-May-13 0:50am    
Agreed except I would suggest /W4
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900