Re: dll troubles

From: Dave Townsend (datownsend_at_comcast.net)
Date: 05/27/04


Date: Thu, 27 May 2004 13:59:58 -0700


LabRat,

you have a potential memory corruption problem, and without
knowing much about your application its just about impossible
to help you.

Has this code ever worked - ie, was it working in a static library before ?
hint - you might have problems if something is allocated by the code in the
dll
and deleted by the executable code.

If you are using MFC ( which I guess you are ), there is a CheckHeap()
function
which you can insert at strategic points in your program:

ASSERT( CheckHeap() );

to try to narrow down the problem. You could also use Purify if you have
a license,
although I'd explore the previous function first since it works very fast
and you might get
to the point quicker.

You should be able to trace down the problem by using the VC++ debugger, run
to
the place where the error happens and then look at the stack of calls to see
whats
happening. I suspect you are deleting memory twice, deleting something
which is
not a pointer, deleting something allocated with malloc/calloc, overwriting
a block
of memory and corrupting the heap bookkeeping structures.

dave

"LabRat" <eranders@lynx.neu.edu> wrote in message
news:4d995b33.0405270735.3b043aee@posting.google.com...
> I've been working lately to build a dynamic library (in this case, a
> win32 dll) and I have encountered huge problems with it. This is my
> first real attempt at doing anything like this, so it's been a
> learning experience for me. I have gotten the dll to build
> completely, but now I'm having a hard time getting the application
> using it to run. When I run the executable I've made it generates
> runtime errors:
>
> Debug Assertion Failed!
> Expression: _CrtIsValidHeapPointer (pUserData)
>
> Is this a common problem? Or do I have a lot more debugging to do?



Relevant Pages

  • Re: Internet Explorer does not seem to release reference to ActiveX dll
    ... Though it turns out that deleting ... It works but it forces a re-boot as the DLL can't ... do you mean removing the dll from memory? ...
    (microsoft.public.scripting.vbscript)
  • Re: Why do we need executables in certain formats ?
    ... > complex binary formats was that programs need to be relocated, ... > perhaps linked with libraries. ... Modern virtual memory processors can locate to ... > has a hidden problem with the new .DLL. ...
    (comp.lang.asm.x86)
  • Re: Why is Base3.exe using 700+ K in windows task manager ?
    ... DLL function. ... handles opened by any thread of the calling process ... The DLL allocates memory from the virtual address space of the calling ... Who can tell where memory is really located in a virtual adress space? ...
    (alt.lang.asm)
  • Re: shared DLL VS static Link, Are they different?
    ... MFC exits, and if there is any memory that is freed at that time, MFC will ... business dumping leaks; it should wait until the CRT DLL dumps leaks after ... ALL RESOURCES OWNED BY THAT PROCESS ARE RELEASED. ...
    (microsoft.public.vc.mfc)
  • Re: Linking to a .NET dll from C#
    ... for obtaining price quotes and performance is absolutely critical. ... be to use shared memory or memory mapped files. ... Be aware that in these scenarios you're responsible for patching and updates, as the application will no longer rely on the clients machine to keep the framework up to date. ... Determine if a certain managed .NET dll or assembly is loaded ...
    (microsoft.public.dotnet.general)

Loading