?
Solved

Debug Assertion Fail (MSVC++ 4.2)

Posted on 1997-03-04
1
Medium Priority
?
1,582 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
gvg earned 200 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

765 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