By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,918 Members | 2,294 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

dll troubles

P: n/a
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?
Jul 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

"LabRat" <er******@lynx.neu.edu> wrote in message
news:4d**************************@posting.google.c om...
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
Jul 22 '05 #2

P: n/a
On 27 May 2004 08:35:26 -0700, er******@lynx.neu.edu (LabRat) wrote:
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).
--
C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Jul 22 '05 #3

P: n/a

"LabRat" <er******@lynx.neu.edu> wrote in message
news:4d**************************@posting.google.c om...
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 news:comp.os.ms-windows.programmer.win32.
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
Jul 22 '05 #4

P: n/a

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" <er******@lynx.neu.edu> wrote in message
news:4d**************************@posting.google.c om...
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?

Jul 22 '05 #5

P: n/a

"LabRat" <er******@lynx.neu.edu> wrote in message
news:4d**************************@posting.google.c om...
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
Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.