Solved

Debug Assertion in Release build

Posted on 1998-05-19
3
395 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
[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
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 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