Solved

Debug Assertion in Release build

Posted on 1998-05-19
3
388 Views
Last Modified: 2013-11-20
I've build a large project, and have now tried to build it in release mode.  I get the following:
Debug Assertion Failed
File: dbgheap.c
Line 1051    ( I think this is in v_free_dbg)

The code that causes this is:

(in OnInitUpdate, this the setup and its OK)
               // Pre Bill Tab
    m_pbTab = new CPbInvDlgTab(m_client, m_matter, m_invList, this);
    VERIFY(m_pbTab->Create(CPbInvDlgTab::IDD, &m_wipTabCntl));


(OnDestroy)
    m_pbTab->DestroyWindow();
    delete m_pbTab;         // This blows up here with the debug assertion

(These are views that are used in a TAB control)

I have searched all though the code for any conditional  DEBUG code that may be getting included in the release mode.  The view getting destroyed has vendor provided OCXs.  As well I'm using third party STL lib, but I have included only their release LIBS.

A pointer as where to look next would be great help.  This all runs OK in DEBUG build. Am I on the right track in assuming that some DEBUG build code is doing a delete etc?

Chris Sadler

0
Comment
Question by:csadler
  • 2
3 Comments
 
LVL 3

Expert Comment

by:Norbert
ID: 1312643
is it possible that you deleted some
#ifdef _DEBUG
directives
at the beginning of the most appwizard /classwizzard generated files you found:

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

I don't know what happens in release build if these ifdef directive is deleted

BTW I am sure that some debug code is doing the delete
because assertions are impossible in release as I know

HTH
    Norbert
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 70 total points
ID: 1312644
DBGHEAP.C comes from the debug version of the C runtime libraries. If you're getting an assertion in this module after a release build, you've not done a true release build: something's wrong with the way you're building, or something's wrong with the way one of your modules is linking.

Normally, an MFC application links to a particular set of runtimes based on _DEBUG being defined. AFX.H will emit a special record into the *.OBJ file of your application instructing the linker to go fetch the version of the runtime libraries that match the type of build you're preforming. If you've explicitly defined _DEBUG, you can screw-up this mechanism.

Normally, _DEBUG is implicitly defined by the compiler when you use one of the /M options on the compiler command-line or when you select a runtime library in the "C/C++" tab of the "Project Settings" dialog.

If you've somehow linked both debug and non-debug C runtimes into your application, you're very likely causing the assertion by allocating some memory with the non-debug runtimes and freeing it with the release runtimes (or vice-versa).

.B ekiM


0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1312645
The #ifdef's around redefinitions of new in your own source code are inconsequential.

MFC defines DEBUG_NEW to point at the debugging operator new only if _DEBUG is defined, and points at regular operator new if _DEBUG isn't defined.

.B ekiM

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 53
Separate files macro - Errors on larger data set 18 65
Sed question 2 68
Detect file exist or not 3 130
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

911 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

28 Experts available now in Live!

Get 1:1 Help Now