dll troubles

L

LabRat

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?
 
M

Mike Wahler

LabRat said:
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?

Yours is not a C++ issue, but an issue with the Microsoft
Windows operating system. Ask about this at
comp.os.ms-windows.programmer.win32

Purpose of comp.lang.c++:
http://www.slack.net/~shiva/welcome.txt

-Mike
 
T

tom_usenet

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?

This newsgroup only covers standard C++, not platform specific issues.
Try over in microsoft.public.vc.language.

(Off-Topic hint: make sure that the dll and the exe are both compiled
against the Multithreaded DLL version of the runtime library, either
both the debug one, or both the non-debug one - see project
settings->C\C++->Code generation).
 
J

John Harrison

LabRat said:
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?

Its a very common problem, it means your code has a bug in it. But without
seeing any code it really could be almost anything.

Since you are programming Windows you might be advised to ask this on a
Windows programming group, such as Your problem could be a generic C++ one in which case feel free to ask about
it here or it could be something specific to Windows in which case ask on
the above group.

I would advise, if you ask again, to give a teeny bit more information, such
as some of the problems you encountered and some of the code. Without those
absolutely no-one is going to be able to help. Also before asking again try
narrowing down the problem by removing as much code as possible, then post
the remaining code.

john
 
D

Dave Townsend

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
 
G

Goran Sliskovic

LabRat said:
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?

It can happen if you allocate memory in main program and free it in .dll or
vice versa. .dll has separate heap, you have to delete memory allocated in
dll in context of that dll.

Regards,
Goran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,125
Latest member
VinayKumar Nevatia_
Top