Heap overrun exception in an MFC app only

65 views
Skip to first unread message

Guillaume Seguin

unread,
Mar 13, 2012, 9:37:28 PM3/13/12
to lo...@googlegroups.com
I build the test application with Visual Studio 2010. It runs fine. 

I create a simple MFC application using VS wizard. I added this code (in the About box handler function) :
 
LOGOG_INITIALIZE();
logog::LogFile errFile("log.txt");
LOGOG_SHUTDOWN();

LOGOG_SHUTDOWN throws an Heap overrun error.


The output windows has this :

HEAP[mfctest.exe]: Invalid address specified to RtlValidateHeap( 006B0000, 0019F3C4 )

Here is the stack trace :

  ntdll.dll!_RtlpBreakPointHeap@4()  + 0x23 bytes
  ntdll.dll!_RtlpValidateHeapEntry@12()  + 0x30eb3 bytes
  ntdll.dll!_RtlValidateHeap@12()  + 0x7a bytes
  KernelBase.dll!_HeapValidate@12()  + 0x14 bytes
  msvcr100d.dll!__CrtIsValidHeapPointer()  + 0x40 bytes
  msvcr100d.dll!__free_dbg_nolock()  + 0x11a bytes
  msvcr100d.dll!__free_dbg()  + 0x50 bytes
  msvcr100d.dll!_free()  + 0x10 bytes
> mfctest.exe!logog::Object::Deallocate(void * ptr)  Line 128 + 0x10 bytes C++
  mfctest.exe!logog::Object::operator delete(void * ptr)  Line 69 + 0x9 bytes C++
  mfctest.exe!logog::LogFile::`scalar deleting destructor'()  + 0x3c bytes C++
  mfctest.exe!logog::DestroyAllNodes()  Line 334 + 0x3b bytes C++
  mfctest.exe!logog::Statics::Reset()  Line 32 C++
  mfctest.exe!logog::Shutdown()  Line 69 C++
  mfctest.exe!CmfctestDlg::OnSysCommand(unsigned int nID, long lParam)  Line 114 C++

I tried the following, but I still see the same behavior :
  • Moving the 3 lines of code about around in the app
  • Building the app with static libs
  • Running a release build. 

Could there be some sort of conflict with MFC allocators ?

John Byrd

unread,
Mar 14, 2012, 2:26:31 AM3/14/12
to lo...@googlegroups.com
The errFile object still exists when LOGOG_SHUTDOWN() is called.  Try deleting it before calling LOGOG_SHUTDOWN().

Enough people are making this mistake that I'm probably going to put it in the docs somewhere.

jwb


--
You received this message because you are subscribed to the Google Groups "Logog" group.
To view this discussion on the web visit https://groups.google.com/d/msg/logog/-/nAtX02xwYmAJ.
To post to this group, send email to lo...@googlegroups.com.
To unsubscribe from this group, send email to logog+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/logog?hl=en.



--
---

John Byrd
Gigantic Software
2102 Business Center Drive
Suite 210-D
Irvine, CA   92612-1001
http://www.giganticsoftware.com
T: (949) 892-3526 F: (206) 309-0850

John Byrd

unread,
Mar 14, 2012, 3:07:32 AM3/14/12
to lo...@googlegroups.com
I went ahead and put more information about how to create a working logog hello world type sample in the Quick start docs, at  http://johnwbyrd.github.com/logog/quickstart.html .  Hope it helps.

jwb

Guillaume Seguin

unread,
Mar 14, 2012, 12:17:48 PM3/14/12
to lo...@googlegroups.com
That was it !

Destroying the errFile object was the issue, it had nothing to do with MFC. Thank you !


--
Guillaume
jwb


To unsubscribe from this group, send email to logog+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/logog?hl=en.
--
---

John Byrd
Gigantic Software
2102 Business Center Drive
Suite 210-D
Irvine, CA   92612-1001
http://www.giganticsoftware.com
T: (949) 892-3526 F: (206) 309-0850
Reply all
Reply to author
Forward
0 new messages