I had an applications programmer come running down to my desk the other day. She was in a major panic, and blurted out that there must be something wrong with the operating system or network. After calming her down a little, I asked her what the problem was, and she told me that one of their programs, although it had told them that it had done its job and deleted the records it had been asked to, had really done nothing at all.
Unsurprisingly, I didn't think this was a systems or network issue. I asked to look at the code that was failing, and also unsurprisingly, there were glaring errors in it. I must point out that the bugs in the code were latent, and were not of this programmer's manufacture. The code is over fifteen years old.
The problem turned out to be that the code was opening a file for shared update, and failing to check the return status.
Triggering the bug turned out to be the fact that the applications team had just deployed another program that opened the same file in exclusive update mode. The first program would attempt to open the file and fail, but blithely continue on. Looking further down in the code, the program did the same thing with the delete statement. It called delete, which failed because the file was not open, but because the return status was not checked, it reported it had successfully deleted what it had been asked to.
Checking return status is considered important. OpenVMS offers a rich condition signalling and handling facility. Please use it.
For the C coders out there, here is an indispensable piece of code:
#include <stsdef.h> #include <lib$routines.h> #define errchk_sig(arg) if (!$VMS_STATUS_SUCCESS(arg)) \ (void)lib$signal(arg);Posted at November 3, 2002 10:38 AM
Comments are closed