R6025 - pure virtual function call


  • I have a vb.NET application which sometimes craches and gives the error:

    R6025 pure virtual function call
    this is a run-time error in Visual C++

    This is followed by:

    LoaderLock was detected
    Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

    And thats weird... cause I don't have any C++-code in this project. (unless NI implements in C++)

    Does anybody know what could be the problem?

    Tuesday, May 16, 2006 2:43 PM

All replies

  • Peculiar.  Just about every application has C++ code running somewhere because the CLR and Windows itself are written (at least portions of it) in C/C++.  The LoaderLock issue is caused by someone attempting to use managed code in DllMain.  When a DLL loads the OS takes a local temporarily to ensure the DLL is loaded thread-safe.  However the CLR also needs to load some DLLs.  Therefore if you are in the middle of loading your DLL and the CLR is then loaded it'll deadlock.  This whole issue has been well documented.  In fact in 2.0 I believe this issue has been resolved or at least worked around completely such that you don't have to worry about it. 

    Nevertheless if your application loads any DLLs then you need to ensure that each DLL does not attempt to load managed code in DllMain.  Note that many ActiveX controls are written in C++ so instantiating an ActiveX control may be enough to cause the problem.  The nice thing about this error though is that it should be pretty easy to track down the DLL causing problems if you are running through the debugger or if you run the application under Depends (with profiling) or another tool that logs DLL loading.  The problem DLL will probably be the last DLL loaded.  Of course if you are getting an actual exception then the exception should also tell you what is going on.

    As for the pure virtual function error it is normally caused by attempting to use a method of a class in a DLL that is older than the public interface you wrote your code to.  It theoretically can not happen if all the code is compiled because the compiler will catch such an error but with DLLs it is a little different.  For example assume you create an interface called IMyInterface with a method called Foo and store it in the DLL MyInterface.dll.  Now assume that you create a new DLL called v1.dll that contains a class that implements IMyInterface.  Later on you extend IMyInterface with another method Bar.  If you fail to update the v1.dll then at runtime when you call IMyInterface.Bar on the class from v1.dll it is an error because the function does not exist.  Yet the compiler can't help you out because when you originally compiled v1.dll the Bar method did not exist.

    Hope this helps,
    Michael Taylor - 5/17/06

    Wednesday, May 17, 2006 12:31 PM
  • While using IE 7, I get Runtime Error  Program C:\ProgramFiles\Internet Explorer\Iexplore.exe

    R6025   pure virtual function call


    I reinstalled IE 7 but it didn't help.  any suggestions?


    thank you


    Wednesday, September 12, 2007 3:00 AM
  • I found that it could also be a problem with Adobe Flash and Shockwave. You can go to your add and remove programs and delete both and then try reinstalling from adobe website.
    Monday, August 31, 2009 4:04 PM