Solved

Debug Assertion in Release build

Posted on 1998-05-19
3
386 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

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

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…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

11 Experts available now in Live!

Get 1:1 Help Now