Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2007

Tip: Looking for answers? Try searching our database.

tracking down random memory clobbering, any tools/tips?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jonathan Wilson - 17 Sep 2007 00:50 GMT
I have a closed source app. I have a .dll plugin for this app (which I am
writing). This plugin contains a bug somewhere which seems to clobber
memory in a "random" fashion (as in, its not clobbering any specific
identifiable piece of memory that I can breakpoint on or anything). Are
there any tools out there that I can use to help track this down?
Anyone got any tips to help with this?
Doug Semler - 17 Sep 2007 01:12 GMT
>I have a closed source app. I have a .dll plugin for this app (which I am
>writing). This plugin contains a bug somewhere which seems to clobber
>memory in a "random" fashion (as in, its not clobbering any specific
>identifiable piece of memory that I can breakpoint on or anything). Are
>there any tools out there that I can use to help track this down?
> Anyone got any tips to help with this?

I am presuming that it is a native unmanaged dll.  Usually when you are
stomping on "random" locations, it's because you either are using the wrong
calling convention, or you have an uninitialized local variable in your
function (meaning that while you are using a garbage address, it is still
inside your virtual address space)...

Compile a debug version with the following properties:

Compile Properties C/C++ Code Generation:  Basic Runtime Checks to both
(stack frame and uninitialized variables) - This fenceposts your functions
(this is usually the default, by the way).

You can also do:

#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>

// the following allows me to trap memory problems with "new" in C++ -
doesn't work in all cases but it helps YMMV
#ifdef _DEBUG
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif

You can then check your memory right before you see you are having problems
or right at the end of your functions, which will fire an assertion and
opportunity to debug if there is a memory issue detected by the debug memory
allocation routines.

_ASSERTE(_CrtCheckMemory());

(You can look into the crt debug functions in MSDN for more information.)

None of these options would be included in a release build (_ASSERTE's are
#ifdefed out, /RTC1 is not supported with optimizations enabled).

Signature

Doug Semler, MCPD
a.a. #705, BAAWA.  EAC Guardian of the Horn of the IPU (pbuhh).
The answer is 42; DNRC o-
Gur Hfrarg unf orpbzr fb shyy bs penc gurfr qnlf, abbar rira
erpbtavmrf fvzcyr guvatf yvxr ebg13 nalzber. Fnq, vfa'g vg?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.