Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 665
  • Last Modified:

"pure virtual function call" - heap error

Hi Experts,

I'm getting this heap error in release mode.  I can't reproduce it when trying to make application verifier watch the heap - it interferes with the path of the code in memory too much in my case I guess.  I'm very rusty on how these tools are used- can anyone give me a quick summary of what I need to do to find the offending code causing this?

Thank you!
Mike
0
thready
Asked:
thready
  • 7
  • 3
  • 2
  • +3
5 Solutions
 
jkrCommented:
This one http://msdn.microsoft.com/en-us/library/fsk896zz%28v=vs.100%29.aspx ("How to: Debug a Release Build") might help...
0
 
phoffricCommented:
Works in debug mode but not in release mode often indicates a memory or likely a pointer problem. These tools should solve the problem quickly for you once you understand how to reject the false positives.

IBM Rational Purify (This link has a trial offer):
     http://www-01.ibm.com/software/awdtools/purify/win/

Parasoft Insure++
    http://www.parasoft.com/jsp/products/insure.jsp?itemId=63

I know that Parasoft used to give a 2-4 week free trial evaluation. I used Insure++ on SCO Unix and Windows (integrated into Visual Studio), and it probably saved us at least 1 man year when upgrading our OS. The software had been tweaked to give good results without deep understanding of erroneous code. Insure++ pointed out 100's of issues for them.
0
 
phoffricCommented:
I found this comparison of Purify vs Insure++. Not sure how old it is and whether the comparison holds. But the link is good in that it gives you and idea of some of the errors that these products can detect in run-time environment. (I know Insure++ also has extra compile time useful errors generated, but its main value is in run-time diagnostics.)
    http://char.tuiasi.ro/doace/www.parasoft.com/products/insure/compare/examples.htm
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
threadyAuthor Commented:
Thanks gentlemen, looking into your answers now! :)
0
 
threadyAuthor Commented:
No luck with the release mode build jkr- I still get the "pure virtual function call" runtime error.  I can see that it's within a basic_string copy and there's a stack trace with no indication of where i'm at... but at this point, I'm passed where the problem occurs.

phoffric- I just created a profile and requested an insure++ eval.

I'm a little surprised no one told me to use windbg for this.  I was hoping that you would (so I could ask you how to use it for a heap error!)- is it because it's tough to use? :)
0
 
threadyAuthor Commented:
Actually jkr- I noticed this in the output line in my release build with debug info generated:

"First-chance exception at 0x75ddc41f in Knee3DAssessment.exe: Microsoft C++ exception: Poco::NotFoundException at memory location 0x0018fbb4.."

This looks to me like Poco is trying to access memory that has been corrupted, right?  Anything I can do with this to figure out where the offending code is?
0
 
threadyAuthor Commented:
More info:  just got this in the output window while using application verifier (any idea how to use these addresses?)

First-chance exception at 0x004d18d0 in my.exe: 0xC0000005: Access violation reading location 0x09fd5f58.


===========================================================
VERIFIER STOP 0000000000000013: pid 0x16DC: first chance access violation for current stack trace

      0000000009FD5F58 : Invalid address being accessed
      00000000004D18D0 : Code performing invalid access
      000000000008DC60 : Exception record. Use .exr to display it.
      000000000008D770 : Context record. Use .cxr to display it.
===========================================================
This verifier stop is continuable.
After debugging it use `go' to continue.
===========================================================



=======================================
VERIFIER STOP 00000013: pid 0x16DC: First chance access violation for current stack trace.

      09FD5F58 : Invalid address causing the exception.
      004D18D0 : Code address executing the invalid access.
      0018F7DC : Exception record.
      0018F82C : Context record.


=======================================
This verifier stop is continuable.
After debugging it use `go' to continue.

=======================================
0
 
ambienceCommented:
>> This looks to me like Poco is trying to access memory that has been corrupted, right?  Anything I can do with this to figure out where the offending code is?

Unless theres another instance of it, it just tells that the exception was thrown. First chance exceptions are normal behavior.

With these kind of crashes theres no single way that always works, you can try various different things and get hints leading you to the real cause. In addition to external tools internal application logs (if you have) are really helpful in figuring out a pattern of execution that leads to crash and careful code review along those paths often helps.

Windbg can also help - If you have the pdbs for the release mode then let your program crash and depending on your version of windows you can either use DrWtsn32 to create coredump or other tools (cant remember but latest Windows versions have registry settings to enable coredump creation - you can search google for how to setup coredump creation).

That coredump can be loaded into WindBg and as long as the pdb matches it should give an idea of the location and type of exception - the variables window also works as well as callstack.
0
 
jkrCommented:
>>any idea how to use these addresses?

Build your application with 'Generate Map File' enabled. Using that map file, you can look up the address to see in which function/method that happened.
0
 
threadyAuthor Commented:
points coming soon.  Boss just put me on something else urgent.  Thank you very much for your comments- I'll come back as soon as I can!
0
 
havman56Commented:
int CrashReportingFunction( int reportType, char *userMessage, int *retVal )
{
......
return true;
}


immediately after your main() please install crash hook like this

_CrtSetReportHook( CrashReportingFunction );

when you register crash report function , when invalid memory access happens then this function will get triggered ., you can print whatever you like debug info
0
 
sarabandeCommented:
in case of access violation error, first chance exception handling is not normal behavior. it only means that the usage of a pointer was handled by  a try-catch block. windows does that for example when it calls a function pointer stored with a window for message processing. in case the pointer is not (or no longer) valid the exception was caught (first chance) and it would ignore the error.

however such handling does not solve a problem. it only could be a work-around in case a programmer was not able to handle asynchronous or multi-threaded processing in the correct order and when the code that leads to the exception actually was not needed (at that time). in your case where the program is crashing after the first chance exception, it is much likely that the wrong pointer was used later again but outside of a try block or points to corrupted memory where there is no way out.

the problem with first-chance exceptions is that the actual pointer access (which went wrong) was not revealed because of the exception handling. in debug mode you could help from that in visual studio by a setting. go to menu entry debug\exceptions ... and navigate to win32 exceptions\access violation. here you can check a box which makes the debugger break immediately when the exception was thrown, what means that it breaks regardless whether the exception was handled or not. i hope that this behavior also would work for your release build with debug information.

Sara
0
 
threadyAuthor Commented:
I'm still looking into this- thanks for all the great comments everyone.  Trying to get my hands on trials of purify and insure as well...  Insure++ is tougher to get - and purify doesn't show the problems found with evaluations...
0
 
phoffricCommented:
I believe that in the next few weeks I will be using Purify. Insure++ used to be easy to get for an evaluation. It is a great product. It will be nice to compare with Purify.
0
 
threadyAuthor Commented:
Thanks everyone
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 7
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now