LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

I am getting a "First chance GPF" using exit (EXIT_FAILURE)

In my program I am using exit (EXIT_FAILURE) to terminate if inizialization routine get some error.

This works well on Win98 and W2k, but I am now getting a so-called "First chance" GPF on WinXP (I am using CVI 6.0, working in the IDE): the message has the usual "Break" and "Continue" buttons but the only working possibility is to break execution and to abort program in the IDE.

The compiled program in the same situation works well (no error messages encountered).

What is this "First chance" error and why is it arising on XP?

Thank you for your help
Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 1 of 7
(3,519 Views)
Hello

I tried using XP with CVI 6.0 and made a simple console app. I could not see that you mentioned. Can you post some code that lets me reproduce the problem?
Thanks

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 7
(3,519 Views)
That's my main (). When I get the error I have done very few operations.

int main (int argc, char *argv[])
{
int x = 0, nc;
char a[256];
SYSTEMTIME dh;

if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */

// Decode the name of the program
strcpy (pgm, argv[0]);
if ((nc = FindPattern (pgm, 0, -1, ".", 0, 0)) > 0) pgm[nc] = 0;

//-----------------------------------------------------
// Preliminary checks
//-----------------------------------------------------
SetBreakOnLibraryErrors (0);
// AvvioPgm () functions check for presence of necessary files, read configuration files and open serial port
// It returns 0 in case all is OK, 1 if not
if (AvvioPgm (x)) exit (EXIT_FAILURE); //<<== Here I catch the
error

// Load main panel
if ((mainH = CaricaPannello (0, UIR, Main)) < 0)
return -1;
if (BeingDebuggedByCVI ()) {
// Customizations in case of execution in the IDE
}
// Other customisations
SetPanelAttribute (mainH, ATTR_WINDOW_ZOOM, VAL_MAXIMIZE);

//-----------------------------------------------------
// Start user interface
//-----------------------------------------------------
RunUserInterface ();

//-----------------------------------------------------
// Program end
//-----------------------------------------------------
arrtot ();
DiscardPanel (mainH);

// Free dynamic memory
if (rawDb) free (rawDb);
if (rawSp) free (rawSp);

return 0;
}


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 7
(3,519 Views)
Try building and running the attached project and see if you get the same error with this as well. It just sets some panel attributes and loads the panel. The panel only have an ok and a stop button on it.


Bilal
Bilal Durrani
NI
0 Kudos
Message 4 of 7
(3,519 Views)
Dear bilalD, your project works well... and my too, after excluding from it a third-party dll built in LabVIEW for sound measurement!

I'll get in touch with the dll producer to discover what is happening.

I am sorry for the time you wasted on this subject. Thanks for your help.

Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 7
(3,519 Views)
But anyway, what was confusing me was that "first chance" attribute of the GPF I didn't find in the documentation: what is it referring to?


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 7
(3,519 Views)
A first chance execption is a type of exception that always gets reported to the debugger first. In most cases, if the exception is a problem, the code usually handles it, but the special things about first chance exceptions is that the debugger usually prints something out about it, regardless of whether it was handled in the code or not. So the debugger always gets to see the exception first, hence the name first chance exception. Usually its something like a stack overflow, segmentation violation ,etc.

You can set CVI to capture first chance exceptions by using the SetBreakOnFirstChanceExceptions() function. But in most cases, first chance exceptions are handled by the app ( or dll) and usually not allowed to propagate out.
So you normally would not want the debugger to capture every first chance exception it finds, because there might be alot, but all of them might be getting handled.

Bilal
Bilal Durrani
NI
0 Kudos
Message 7 of 7
(3,519 Views)