Solved

Debug Assertion in Release build

Posted on 1998-05-19
3
391 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 121
Excel Use VBA to get user's Mac Address for their computer 5 160
sum28 challenge 31 111
fizzArray2 challenge 1 79
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

776 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