Re: Error Handler BUG!!
Posted in 1995
>Date: Tue, 7 Feb 1995 09:32:57 -0800 (PST) >From: Robert Minter <rob@dssmktg.com> >X-Informix-List-Id: <list.5508> > >>From Storm Software: >* From: Storm Software <aztec.co.za!storm@uunet.uu.net> >* Date: 7 Feb 1995 09:12:54 GMT >* X-Informix-List-Id: <news.11346> >* >* Here's a good one : >* >* SCO UNIX 3.2.4 >* Informix R4GL V.4.11 UC2 >* Informix SE V.5.0 >* >* We use an error handling function in most of our programs so I was >* rather surprised to see one particular error crashing with the >* familiar command line suggestions. >* >* At first I thought it was my error handling routine, but I confirmed >* it wasn't by changing the error handler to WHENEVER ERROR CONTINE, >* just so I could see the status. >* >* I then tried the following program to be absolutely sure. >* >* [See original below -- JL] >* >* I know the program will crash with error -1332, subscripts out of range, >* but it is not caught by the whenever error continue. Change r_char >* to a smallint or something just to get a different fatal error and it IS >* caught by the CONTINUE statement. >* >* How is this one slipping through? (Jonathan?) >* >* Me or it? > >You. If you look in the I-4GL Supplement ( Feb 1992, Part # 000-7171 Rev.A) >on page S-180, it states you need the keyword ANY to set status variable after >evaluating an expression. So: > > WHENEVER ANY ERROR CALL your_error_handler > ^^^ Well, I used the three programs below and version 4.12.UE1 of I4GL-RDS, and got consistent behaviour from all of them -- the program stopped with one of two fatal errors (-1332 or -1326), never executing the DISPLAY statement. I ran with both 'WHENEVER ERROR' and 'WHENEVER ANY ERROR'. I4GL-RDS (p-code) has to be fussier than compiled I4GL (c-code) because if it allows the programmer to trample outside the bounds of the allocated variables, the program will trash p-code control information and render the program completely unreliable in short order. The c-code system is built on the C compiler, and the C compiler doesn't lose as much information when the program goes trampling outside the variables. Accessing data outside the range of valid values should never be condoned, in my view, even though the c-code version of I4GL allows you to get away with it by default. You certainly shouldn't code a program to rely on it being possible to do so -- the results are inherently unreliable. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> -- Original MAIN DEFINE x SMALLINT DEFINE r_char CHAR(10) WHENEVER ANY ERROR CONTINUE LET x = 0 LET r_char[x] = "H" DISPLAY "Program completed" END MAIN -- Array of CHAR MAIN DEFINE x SMALLINT DEFINE r_char ARRAY[10] OF CHAR(10) WHENEVER ANY ERROR CONTINUE LET x = 0 LET r_char[x] = "H" DISPLAY "Program completed" END MAIN -- Array of non-CHAR MAIN DEFINE x SMALLINT DEFINE r_char ARRAY[10] OF SMALLINT WHENEVER ANY ERROR CONTINUE LET x = 0 LET r_char[x] = 1 DISPLAY "Program completed" END MAIN