Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

MFC CRecordset heap corruption detected at Close()

906856Oct 29 2013 — edited Nov 6 2013

I recently upgraded my operating system from Windows XP to Windows 7 SP1 64 bit. We are using Visual Studio 2005/2008  Professional Edition and Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production.

When I try to execute this code I am getting the below exceptions.

try {

  CDatabase *pDatabase = CDatabaseConnection::getDatabaseConnectionProcessLog();

  ORSProcessLog rsProcessLog(pDatabase);

  CString strFilter = _T("SELECT PROCESS_ID, MESSAGE FROM OP_PROCESS_LOG");

  rsProcessLog.SetRowsetSize(1);

  if( !rsProcessLog.Open(CRecordset::dynaset, strFilter, CRecordset::appendOnly) ) 

  return;

  if( !rsProcessLog.CanAppend() )

  return;

  rsProcessLog.AddNew(); 

  rsProcessLog.m_PROCESS_ID = gcsProcessID;

  rsProcessLog.m_MESSAGE = csMessageA;

  rsProcessLog.Update();

  rsProcessLog.Close();

}

catch ( CDBException* pEx )

{

  bException = true;

  pEx->GetErrorMessage(szCause, 255);

}

catch( CException* pEx )

{

  bException = true;

  pEx->GetErrorMessage(szCause, 255);

}

where rsProcessLog is the CRecordset object using a successfully connected database pointer pDatabase

In 32- bit Debug version I get a message box at rsProcessLog.Close(); with the below text

Debug Error

Program: ......\Test.exe

HEAP CORRUPTION DETECTED: after Normal block (#506) at 0x0087F628. CRT detected that the application wrote to memory after end of heap buffer.

Memory allocated at f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dbcore.cpp(2626)

(Please Retry to debug the application)

In 32- bit Release version I get a message box at rsProcessLog.Close(); with the below text

Windows has triggered a breakpoint in Test.exe

This may be due to a corruption of the heap, which indicates a bug in Test.exe or any of the DLLS it has loaded.

This may also be due to the user pressing F12 while Test.exe has focus.

The output window may have more diagnostic information.

The above code was a working code in Windows XP with the rest of the env remaining the same and it continues to run in Windows XP but not in Windows 7. Any help will be greatly appreciated.

This post has been answered by 906856 on Nov 6 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 4 2013
Added on Oct 29 2013
10 comments
5,677 views