04-17-2013 01:39 PM
I am new to NI CVI environment and running a C code in CVI 2012 that reads data from PXI DAQs using a registered event callback.
Running the application, I get the following error in the middle of the run:
FATAL RUN-TIME ERROR: Unknown source position, thread id 0x0000152C: The program has caused a 'General Protection' fault at 0x6D9E0C6B.
The address is within the nicaiu.dll module, as reported on the modules window. Once this happens all of the modules are showing "Not Loaded" except for my own .exe application.
Any idea, what could be causing this? Could this be related to any possible memory corruption? Any settings in th CVI?
Could it be related to the modules being unloaded before my app? If so, what could cause the modules to get unloaded?
Thank you
04-18-2013 09:20 AM
HI mjr1357
General Protection faults are ususally memory related issues within programs. General protection faults can be caused by trying to access null pointers or invalid blocks of memory. Are you able to reproduce the crash at the same point within your code upon every run? That would likely point to a null pointer, non initialized connection, or trying to operate on an unloaded module.
Another tool available is to use the Resource Tracking option, which you can use by setting your debugging level to Extended (Options->Build Options menu), and then select resource tracking (Window->Resource Tracking menu) and run your program. You can find more information about resource tracking on the manual page at http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/usermanual/prjwindowrestracking/
The big thing will be trying to figure out the exact conditions that reproduce the issue. I would try to see if you can pinpoint the exact point of failure. That will give the best starting point for debugging this issue.
Regards,
04-18-2013 09:56 AM
Hi,
Thanks for your reply. I could solve the problem. Since the error was stating "Unknown source position", it pointed me towards
the possibility of a corruption in a callback. In fact, I am using DAQmxRegisterEveryNSamplesEvent to register a callback.
That function was getting called a few times (with errors related to reading overwritten samples), so it was not initially clear that this
function pointer might be corrupt. However, when I double checked, I realized that the calling convention for the callback function
is not explicitly specified to CVICALLBACK (the code is trnasformed from an older DAQmx on Linux). Adding the calling convention immediately got rid of this general protection fault problem.
MJR