Access Violation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Airslash
    New Member
    • Nov 2007
    • 221

    Access Violation

    Hello,

    I'm getting the following error message when I try to run my Nunit test cases :

    EAccessViolatio n : Access violation at adress 0000000000

    I think I narrowed it down to my static method for initializing a critical section.
    This is the function :

    Code:
    //---------------------------------------------------------------------------
    // Initialize the critical section for our DriveManager class as well. This
    // allows us to properly create a Singleton instance in a thread-safe
    // environment.
    // Needs to be called on application startup !
    void BigBrother::IO::DriveManager::Initialize()
    {
    	// Initialize the critical section.
    	::InitializeCriticalSection(&cs_drivemanager);
    
    	// Set our flag to true.
    	BigBrother::IO::DriveManager::initialized = true;
    }
    I'm pretty sure this is causing the violation as that was the only call in the unit test, everything else was in comment.

    in the CPP file I also have the following declared:

    Code:
    // STATIC VARIABLES ---------------------------------------------------------
    BigBrother::IO::DriveManager* BigBrother::IO::DriveManager::instance = NULL;
    volatile bool BigBrother::IO::DriveManager::initialized = false;
    CRITICAL_SECTION BigBrother::IO::DriveManager::cs_drivemanager;
    //---------------------------------------------------------------------------
    they're static private members of my class.

    Can anyone tell me what I'm doing wrong ?
  • Airslash
    New Member
    • Nov 2007
    • 221

    #2
    ok,

    after further research it's not the Initialize() function, but the Initialized() function.

    Code:
    //---------------------------------------------------------------------------
    // This function returns the private flag of the DriveManager manager
    // and can be used to check if the DriveManager class has been properly
    // initialized.
    volatile bool BigBrother::IO::DriveManager::IsInitialized()
    {
    	return BigBrother::IO::DriveManager::initialized;
    }
    I cannot return a static variable ?

    Comment

    • Airslash
      New Member
      • Nov 2007
      • 221

      #3
      never mind......


      seems nUnit needed __fastcall before every function.
      Added that to my unit cals and it worked....

      Comment

      Working...