Solved

Debug Assertion Fail (MSVC++ 4.2)

Posted on 1997-03-04
1
1,534 Views
Last Modified: 2013-12-03
Hi!

I have a following problem:
When I allocate something in DLL and then I deallocate it
in application I get assertion failure:

Debug Assertion Failed!
File: dbgheap.c
Line: 1076
Expression: _pFirstBlock == pHead

I'm using VC++ 4.2 / Window95.

Simple demonstration of the problem:
===========================
DLL code:
---------------
__declspec( dllexport ) int* AllocInt()
{
      return new int;
}

Application code:
-------------------------
__declspec( dllimport) int* AllocInt();

void main()
{
    int* i;
    i = AllocInt();
    delete i;  // causes an assertion failure
}

Thanks for help
            Zdenek

---------------------------------------------
Zdenek Zemanek
<zemanek@cit.cdrail.cz>
---------------------------------------------
0
Comment
Question by:zdenekzz
1 Comment
 
LVL 1

Accepted Solution

by:
gvg earned 100 total points
ID: 1298720
Here is my guess.  
If you look at line 85 in dbgheap.c you can see that _pFirstBlock is
a static variable in dbgheap.c.  Now if your DLL is compiled in
a release version in witch case it doesn't use dbgheap.c the _pFirstBlock
variable in dbgheap.c will not be right when you use debug delete.

In short.  You are using Release new while using Debug delete.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now