10-05-2020 04:12 PM
I have had no luck finding "exception handler" or "fault handler" for this environment. Somewhere in our code there are occasional crashes where the app just disappears. I would like to at least get some kind of "This program has had a XXXX FAULT" error box to aid in debugging.
To explain, make a program with a bad memory copy like:
char *ptr = NULL;
memcpy (ptr, "hello", 100);
When that code is hit, the program just disappears. I'd like to be able trap NULL pointers and other exceptions/faults that may be happening.
Is this possible? I found one post saying you have to use an externa program that launches the LabWindows program, and looks at how it crashes.
Solved! Go to Solution.
10-05-2020 05:04 PM
Per some forum searches, I tried to experiment with:
__try {
...
} __except(x) {
...
}
This does seem to skip over an exception rather than crash, but I need to be able to detect and report what the exception was, for debugging.
10-05-2020 05:45 PM
While I don't know the answer to your question, in a similar situation I could get some info by looking at the OS event viewer, that reported me of crashes including the memory location where they occur and matching that data with the map file created during compilation (an optional element in Build >> Target settings... panel).
10-06-2020 10:12 AM
Thanks -- I do not see anything obvious in my Target Settings dialog. We run CVI and it is not the Full version. Am I out of luck? Or does it go by a less obvious name for the generation of the .map file?
10-06-2020 04:46 PM
Don't you see a window like this one?
10-07-2020 11:33 AM - edited 10-07-2020 11:36 AM
Similar, but I do not have the "Generate map file" option. We are using the 2017 edition, and I think it is Base (not Full) so maybe that is a feature our edition is missing.
Actually, I am checking right now and I do see it, and it's already on. I must have gotten into a different screen the other day. Thanks.
10-08-2020 06:30 AM
If that field is checked you already have the map files: they are located into cvibuild xxx\Debug and cvibuild xxx\Release folders, named map_file.txt.
10-08-2020 09:09 AM - edited 10-08-2020 09:09 AM
Thank you, Roberto.
I put in an intentional crash in main():
memcpy (NULL, "hello", 1000);
...and was trying to figure out how to look at the Reliability Log in Windows 10 and find an address that relates to the .map file. The offset/address I saw did not match -- is this because it is jumping to memcpy() code in a library, rather than inline in main()?
10-08-2020 06:32 PM
Normally you cannot expect to find the exact address in the map file: the more complex a function is, the larger the memory area it spans over. What you should do is to find the closest smaller address in the map file, which is the start of the function the exception occurred.
10-09-2020 11:29 AM
Understood. In this case, I saw the start of main() and the functions after it, and the exception was nowhere in that range. This made me think it must be in library code linked elsewhere, and I can't tell it happened inside main() by that address.
i.e.
void CrashyFunction()
{
memcpy (NULL, "crashola", 1000);
}
In the .map file I will find the address/offset of CrashyFunction, but will the exception appear after that, or somewhere else inside memcpy() code (assuming that is not inlined)?
I may just not be reading the exception display output correctly.