views:

60

answers:

1

Hello

I have succesfully implemented the bonjour sdk in a visual c++ console app. but when I am trying to implement the same code in a windows forms app (visual c++) I am receiving weird errors probably related to some local heap problem with the bonjour dll.

The following assertion in the file dbgheap.c fails:

/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));

It would be really helpful if someone knew some resources dealing with this kind of problem.

Thanks a lot for any help

A: 

You haven't provided us with very much information, but one place to start looking is this bit:

it may have been allocated from another heap

Are you freeing objects allocated by Bonjour? Which C runtime library is bonjour.dll linked against? Are you using the same one (DLL or static, multithreaded or not, debug or release) in your forms app? Are you using the same one as in your console app?

In general it's a bad idea to free memory allocated in other dlls for this sort of reason. Isn't there a BonjourFree function you can call to deallocate objects allocated in Bonjour?

Alternatively you may be overrunning a buffer and overwriting the debug memory allocation boundaries indepdently on Bonjour. Try looking at the memory at the failing free and see if it looks correct.

Rup
yes i am using the same dll. the problem happens as soon as i call a function from the bonjour api dns_sd.h. the wired thing is that this code is never called. the assertion failure happens before that.i think the problem could be the c runtime lib but i do not now how to check or change the linkage of the bonjour dll.