Solved

Debug Assertion Fail (MSVC++ 4.2)

Posted on 1997-03-04
1
1,564 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C#: need to import an entire CSV file 4 60
Dialogbox API leak? 18 108
Developing a front end to SPLUNK 1 50
How Do I Widen a Column in a SharePoint 2013 List 2 30
This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…

680 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