Discussion and Support for the OptiTrack, SmartNav and TrackIR brands by NaturalPoint

Tracking Tools access violation exception

by pdenbrook » Thu Nov 01, 2012 10:24 am

Under certain circumstances, the Tracking Tools software appears to cause the application program to crash with a 0XC0000005 access violation exception. This occurs when Tracking Tools is linked to a dynamically loaded interface DLL (which handles calls to Tracking Tools on behalf of the main application program) and either [1] the OptiTrack cameras are not connected to the system or [2] both a TrackIR 5 camera and the OptiTrack cameras are connected to the system. The access violation occurs when the interface DLL is being terminated by the main application program (via a call to AfxFreeLibrary), specifically, just before the interface DLL returns from DLLMain.

The access violation does not occur when only OptiTrack cameras are connected to the system. When both TrackIR and OptiTrack cameras are connected via USB, the OptiTrack tracks normally, but causes an access violation exception upon termination. The TrackIR, however, does not track normally when the OptiTrack cameras are connected, further indicating there is some conflict going on between the devices.

Note that the access violation exception always occurs when the OptiTrack cameras are not connected to the system. A call to TT_Initialize() returns code 11 (invalid license), but otherwise there is no problem until termination. The access violation exception does not occur, however, if TT_Initialize() is not called, even if TT_FinalCleanup() is called before terminating.

Also note that the access violation exception usually (though not always) occurs when both TrackIR and OptiTrack cameras are connected.

I have isolated this behavior in a simple test program, which I can send to you upon request.
Posts: 3
Joined: Fri Dec 01, 2006 7:17 am

by jolsonsalem » Thu Nov 01, 2012 11:34 am

You can send the test program to

Also, which type of cameras beside the TrackIR are you using?
Posts: 323
Joined: Thu Oct 11, 2012 9:18 am

by Friggincomputers » Thu Mar 07, 2013 12:26 pm

I have a similar problem (with version 2.5.2 and V120:Duo); when dynamically loading the DLL, some of the initialization cause the enclosing function to crash on exit.

The DLL is loaded without any problem, the functions are retrieved correctly and all calls return "success". But the function enclosing this initialization (init) causes an access violation on exit. And only when compiled in release mode.

Simplified, this is the function that never returns:

Code: Select all
void NPTrackingTools::init()
    bool loadSuccess = trackingToolsDllLoad(); //::LoadLibrary(); ::GetProcAddress();
    if( loadSuccess )
        if( mStatus == UNINITIALIZED )
            NPRESULT initResult = FP_TT_Initialize();
            if( initResult == NPRESULT_SUCCESS )
                mStatus = INITIALIZED ;

    if( mStatus == INITIALIZED )
        NPRESULT projectLoadResult = FP_TT_LoadProject( filename );

        if( projectLoadResult == NPRESULT_SUCCESS )
            if( FP_TT_TrackableCount() > TRACKABLE_INDEX &&
                FP_TT_TrackableEnabled(TRACKABLE_INDEX)     )
                mStatus = READY ;
                mStatus = BAD_PROJECT ;
            mStatus = BAD_PROJECT ;
Posts: 2
Joined: Wed Jan 02, 2013 2:21 pm

by Friggincomputers » Thu Mar 07, 2013 2:54 pm

I figured out the problem:

The Trackingtools functions are __cdelc. I was defining my functions as __stdcall.
Posts: 2
Joined: Wed Jan 02, 2013 2:21 pm

by orhirshfeld » Tue Apr 28, 2015 6:57 am

I have similar problem when using Matlab with Tracking Tools or Motive

first i tried using LoadLib and CallLib and get errors

Than i tried using C Mex file and got also an error
so i debug it using Visual Studio and got the following message
Unhandled exception at 0x000007FEDBEEFD1D (NPTrackingToolsx64.dll) in MATLAB.exe: 0x80000001: Not implemented (parameters: 0x0000000000000001, 0x000000010837002E).

also when i looked in the Header file:
Code: Select all
#define TTAPI __declspec(dllexport)
#define TTAPI __declspec(dllimport)
#define TTAPI 

TTAPI   NPRESULT TT_FinalCleanup();

Posts: 16
Joined: Tue Jun 17, 2014 9:42 am

by saverill24 » Wed Aug 19, 2015 11:13 am

I have a what appears to be the same or similar issue as the original poster however with slightly different circumstances. I am using LabVIEW 2014 and the Tracking Tool .dll that remain inside Motive (the new name for tracking tools). When I press stop there is some sort of error when calling the shutdown function in the .dll. When I close a .vi that was running the connection to Motive (the cameras, markers, and rigid bodies as well as other miscellaneous data come through great while its running) LabVIEW crashes with an 0xC0000005 Access Violation error. Which from what I have founds seems to be a pretty broad error, but I am not sure. Any help figuring out the exact source of this error (obviously something to do with closing/stopping the program) would be greatly appreciated.
Posts: 5
Joined: Wed May 20, 2015 5:28 am

by steven.andrews » Fri Aug 21, 2015 9:10 am

Hello saverill24,

Thank you for reaching out to us regarding your crashes. It would help us if we could view the code you are running that is causing the crash.

Could you please open a ticket with us at ? Here, you can submit your code to us so we can troubleshoot this issue and track our progress.

Best regards,
Steven Andrews
OptiTrack | Customer Support Engineer
NaturalPoint Employee
NaturalPoint Employee
Posts: 434
Joined: Mon Jan 19, 2015 11:52 am

Return to Tracking Tools