I have build a dynamic library in both debug and release mode. In the Source code of this libray relloc() function is used. I am linking this libray to my executable application. When i execute the application in debug mode, the application is crashing with the following message

"Unhandled exception at 0x7c90120e in MyApplication.exe: User breakpoint."

When I debug, the application is crashing as realloc() function call.

But when I run in release mode the application is working fine.

Can any body know the reason why the crash is occurring in debug mode and how to fix this problem??

Thank in advance.

Recommended Answers

All 4 Replies

Memory allocated in a dll must be free'ed in the same dll. Likewise, memory allocated in the application program must be realloc'ed or free'ed in that same application program. You can't allocate in one and realloc or free in the other. The reason is that they use different allocation pools (heaps).

>>and how to fix this problem
There is none, other than to do it correctly.

Additioonal information here

And more information from one of the Microsoft developers (I think it is) He makes the suggestion how to resolve the problem.

Allocation, reallocation and free is done in the some libray module.

Same code is working fine in release mode.

Allocation, reallocation and free is done in the some libray module.

Same code is working fine in release mode.

Have you made sure that your memory is not released somewhere else before realloc() call?
Have you done proper return checks of re alloc?
Are you able to see the values of pointer and size are proper before you pass it to realloc using a debugger?

It could, of course, be some other problem in the code which just shows up during realloc. Strange things happen after buffer overruns or other problems.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.