Solved

Problem using DLLs (debug mode)

Posted on 2002-04-30
15
360 Views
Last Modified: 2013-11-20
I have a problem with a DLL in debug mode. When the application that use the DLL starts (in debug mode), it crashes showing the message Debug Assertion Failed.  Program .... Expression: _CtrlIsValidHeapPointer(pUserData).
In release mode the application works correctly (the DLL is in release mode too).
The error is caused by an ASSERT sentence (only available in debug mode).

I would like to know what is the reason of this error, and how I could resolve it.
0
Comment
Question by:svillalba
  • 4
  • 4
  • 3
  • +2
15 Comments
 
LVL 1

Expert Comment

by:Mukki
ID: 6981019
I had a similar problem with one DLL. It was build for release mode. Debug allocation routines are different for Release and Debug builds. I turned off debug allocation routines for debug builds.
Check _AFX_NO_DEBUG_CRT define.

Hope that helps.
0
 
LVL 86

Expert Comment

by:jkr
ID: 6981049
>>I would like to know what is the reason of this error, and how I could resolve it.

The reason is that you are trying to free memory that was allocated in another module. Each exe/dll has it's own allocator/heap unless you change the project settings to use the CRT as a DLL. The memory you are tryng to free is from a different heap, thus the assertion. In Release mode, you'll have a memory leak.
0
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 6981115
BTW: To avoid that, select "Use Runtime Library: Multithreaded DLL" for both the applcation and the DLL - this makes both load the CRT as a DLL, so they share the same allocators.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 4

Expert Comment

by:mblat
ID: 6981117
Assuming you are using VC++.

I had simular problem, the reason for it was that I was using different type of MFC DLL for .exe and .dll.

Go to Project->Settings->C++

In category "Code generation" make sure that you using same "run-time library" for all of mudules in your project.

Hope it helps.
0
 
LVL 4

Expert Comment

by:mblat
ID: 6981124
Sorry jrk - we posted latest comments at the same time - if it is the answer it is yours.
0
 
LVL 86

Expert Comment

by:jkr
ID: 6981135
Well, I explained the problem 15min earlier :o)
0
 
LVL 86

Expert Comment

by:jkr
ID: 6981183
Thank you --- WHY in all the world a "C"?
0
 

Author Comment

by:svillalba
ID: 6981218
Thank you for your answer and sorry for the "C". I didn't mind to choose an "A", but I think "C" is more appropriate. mblat tells me how to resolve the problem (project -> settings -> C++ and so on), whereas you only tell me the reason of the error.
0
 
LVL 4

Expert Comment

by:mblat
ID: 6981255
you know jrk - I kind of glad that that you answered this question first.  :-)

to svillalba:

jrk gave you THE answer.  If you thought that my comment provided you with usefull info you should've gave me some points, either by posting it as separate question or by splitting points you already allocated.  Not to lower grade on perfectly good answer....
0
 

Author Comment

by:svillalba
ID: 6981293
I don't understand why I should have gave an "A" to jrk. I'm grateful to jrk, Mukki and you for your answer. But I thought a "C" was the most appropriate option, that's all. I don't know why is so important.
I accepted his answer because was earlier than yours, but I think your answer is more complete.
Another thing, I don't know how to split points (I didn't know that was possible to do it). I think it was a very good option. As for the other option (posting a separate question) I'm not agree with you, because I think is not a good idea to make blank questions only for points. It's annoying for another users.

Thanks again.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6981766
svillalba -->  Greetings, I see you are fairly new to this site, and some clarification is needed.

The goal is for you to get what you need and to award the first expert who gives you the solution which helps you achieve that goal.  Everyone here strives to deliver "A" level (excellent) information and no one I know of appreciates receiving the lowest grade we have, which is the "C" grade.  In fact, it is always requested that if you feel you have received less than "A" level results, that you let the participating experts know this before you close and grade a question so that they can add what you need to achieve excellence.  The points you assign to a question are always the same, but the points which flow to the experts are a direct result of the grade given.  Example:  100 point question and A = 400 expert points, b = 300, C=200.  Equally important is the fact that some expert look at Asker's grading history and if they see low grades in history, choose not to step in and help.  The total information contained in this question clearly is "A" level information.  Once a questions has been graded, it moves to our PAQ where others can access the information to get help.  Few would consider looking at a "C" question if "A" questions exist, so the grades have even more of an impact than noted earlier.

Any time more than one expert helps you we are happy to process "point splits" for their contributions.  This is done frequently and absolutely the right way to go.  Perhaps that is what should have been done here, and assuming so, I can correct this.

Please check these links for more site-related guidance.
http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp
http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp
http://www.experts-exchange.com/jsp/infoMemberAgreement.jsp

I have changed this grade, and will await a response to process a point split/share adjustment.

Moondancer - EE Moderator
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6981780
Points for Mukki -> http://www.experts-exchange.com/jsp/qShow.jsp?qid=20295576
Points for mblat -> http://www.experts-exchange.com/jsp/qShow.jsp?qid=20295577

I have processed these points for the other two participants here, and did not charge the Asker for these adjustments.

Moondancer - EE Moderator
0
 
LVL 4

Expert Comment

by:mblat
ID: 6981787
Just a small clarification here:  I wasn't asking for any points split, I consider jrk answer complete enough.

I was just pointing to svillalba, that that was an option.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6982204
Understood, I processed the point shares nonetheless for contributions made here and did not charge svillalba.  svillalba now had been advised that Point Split options exist and that to request one, a zero point question in Community Support will receive Moderator assistance.
Moondancer - EE Moderator
0
 

Author Comment

by:svillalba
ID: 6987962
I have read the right method to point the answers and I am agree with Moondancer, mblat and jkr. I should have pointed the question with an "A". Sorry for my mistake and thank you for the explanation.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

808 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