Run Time Error handling In MF COBOL 
Author Message
 Run Time Error handling In MF COBOL

Hi,
        Our environment is MicroFocus COBOL 4.0.16 on Windows 95.

        We are trying to trap Runtime errors like invalid data in
numeric fields. We installed a runtime error handler (RTEH) using the
CBL_ERROR_PROC function. We are observing that
1. RTE are triggered only when we run the .INT version of the code.
   Compiled executables don't get any error. Execution simply carries
   on with junk values.

2. Even with the .INT version we get a memory access violation error
   once we return from the error handler we installed. This happens
   irrespective whether or not we called/blocked previous handlers in the
    chain.

Can somebody shed some light on this? Also does anyone know what errors
we should look for when writing a MF COBOL DLL. We are writing DLLs to be
called  from VB 4.0. The only documentation regarding this seems to be the
README file that comes with the sample. That simply says 'Take care to trap all
errors in COBOL or else the entire application will die.Recommended recovery
is to restart Windows.' There is no info on what to look for and how to do
the trapping. Any info on this ?

Thanks
Uday



Sun, 06 Jun 1999 03:00:00 GMT  
 Run Time Error handling In MF COBOL

Quote:

> Hi,
>         Our environment is MicroFocus COBOL 4.0.16 on Windows 95.

>         We are trying to trap Runtime errors like invalid data in
> numeric fields. We installed a runtime error handler (RTEH) using the
> CBL_ERROR_PROC function. We are observing that
> 1. RTE are triggered only when we run the .INT version of the code.
>    Compiled executables don't get any error. Execution simply carries
>    on with junk values.

I haven't worked with 4.0 yet, but have worked extensively with 3.x.
The specific error you mentioned (trash in numeric fields) could be
turned off with a runtime switch with 3.x (+F or +N I think).
It could also be bypassed via a compiler switch (can't remember that
one).  But if you look at the MF doc closely, it says somewhere that
both these switches apply only to .INT code, not .GNT or .OBJ code.

Quote:
> 2. Even with the .INT version we get a memory access violation error
>    once we return from the error handler we installed. This happens
>    irrespective whether or not we called/blocked previous handlers in the
>     chain.

Don't know much about this, but it seems that if there is a true
memory violation, there wouldn't be any way to keep the runtime from
crashing since it's an operating system exception.

--
Jamie Burks

Phone: 901-922-4472



Sun, 06 Jun 1999 03:00:00 GMT  
 Run Time Error handling In MF COBOL

Quote:


> > Hi,
> >         Our environment is MicroFocus COBOL 4.0.16 on Windows 95.

> >         We are trying to trap Runtime errors like invalid data in
> > numeric fields. We installed a runtime error handler (RTEH) using the
> > CBL_ERROR_PROC function. We are observing that
> > 1. RTE are triggered only when we run the .INT version of the code.
> >    Compiled executables don't get any error. Execution simply carries
> >    on with junk values.

> I haven't worked with 4.0 yet, but have worked extensively with 3.x.
> The specific error you mentioned (trash in numeric fields) could be
> turned off with a runtime switch with 3.x (+F or +N I think).
> It could also be bypassed via a compiler switch (can't remember that
> one).  But if you look at the MF doc closely, it says somewhere that
> both these switches apply only to .INT code, not .GNT or .OBJ code.

In .int code (usually used while an application is in development),
the default is to error on invalid numeric data. The -F runtime switch
disables these errors.

In .gnt (&.obj) code (usually used when an application is in a
production state), speed is of the essence and these checks for invalid
data are not performed (supposedly, you've eliminated any logic
errors by testing the .int code without -F set).

However, you can reinstate the checks into .gnt and .obj code by
compiling with the option "CHECKNUM". Obviously, you will get a speed
and size penalty for having the checks performed before each and every
arithmetic statement in that module.

Quote:
> > 2. Even with the .INT version we get a memory access violation error
> >    once we return from the error handler we installed. This happens
> >    irrespective whether or not we called/blocked previous handlers in the
> >     chain.

This is a different kettle of fish altogether - can you send me a
(very short) source code which demonstrates the problem please ?

Cheers,
Kev.



Fri, 11 Jun 1999 03:00:00 GMT  
 Run Time Error handling In MF COBOL


Quote:
>Jamie

>This is a different kettle of fish altogether - can you send me a
>(very short) source code which demonstrates the problem please ?

>Cheers,
>Kev.

Hi Kevin,
        I sent the following mail to you. I am not sure if it reached
you. Since we are desperate now to resolve this as soon as possible I am
posting this.

Thank you very much,
Uday


Sent:   Tuesday, December 24, 1996 10:30 AM
To:     'Kevin Digweed'
Cc:     'Udayakumar Rajendran'
Subject:        Re: Run Time Error handling In MF COBOL

Hi Kevin,

        Thanks for the reply. I had almost given up hope of getting
more info. One of my colleagues is in touch with MicroFocus support in
USA and he is not making much headway.

        Anyway here is a small sample that demonstrates the
problem. Our environment is Windows 95 and MF COBOL 4.0.26.

        The program basically
1. Installs a run-time error handler(RTEH)
2. Triggers a runtime error by forcing some invalid data into some numeric
   fields and trying to access the data
3. Uninstalls the run-time error handler.

        The RTEH just prints the message it gets and chains to the
previous handler. We have tried commenting out the message printing
line and the line that sets the return code for enabling chaining. We
still get the same behaviour.

        To reproduce the behaviour save the source code at the end of
this note in a file called testcbl.cbl. Then do the following
commands.

C:\>cobol testcbl anim omf(obj);
C:\>cbllink  testcbl
C:\>testcbl
C:\>run testcbl

Running testcbl directly does not produce any error. The screen dump looks
something like
E:\USR\OMNIKRON\ALADIN\TESTCBL\WRK>testcbl
TESTCBL RTEH INSTALLED
SUM = 2:PRD = 00
TESTCBL RTEH UNINSTALLED

Running testcbl via the RUN facility gives the following screen dump.

C:\>run testcbl
Micro Focus Object COBOL (32-bit) V4.0.16
RUN TIME ENVIRONMENT Copyright (C) 1984-1995 Micro Focus Ltd.
URN OXCNM/000318423

TESTCBL RTEH INSTALLED
IN TESTCBL RTEH ERR MSG =
Execution error : file 'TESTCBL.int'
error code: 163, pc=BB, call=6, seg=0
163     Illegal character in numeric field

Execution error : file 'TESTCBL.int'
error code: 114, pc=BB, call=6, seg=0
114     Attempt to access item beyond bounds of memory (Signal 11)


(01 is zero one).

Thanks once again,
Uday

P.S. I have two more minor bugs that would like to report. Whom do I
send these to? I could not find a email address or Web page to which I
could send these.

**************** TESTCBL.CBL ******************
      * -------------------------------------------------------------- *
      $SET ANS85 MF
      * -------------------------------------------------------------- *

       IDENTIFICATION DIVISION.
           PROGRAM-ID.                         TESTCBL.

      * -------------------------------------------------------------- *
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
           SOURCE-COMPUTER. IBM-PC.
           OBJECT-COMPUTER. IBM-PC.

       SPECIAL-NAMES.              
           CALL-CONVENTION 2 IS WinAPI.

      * -------------------------------------------------------------- *
       DATA DIVISION.

      * -------------------------------------------------------------- *

      * -------------------------------------------------------------- *

       WORKING-STORAGE SECTION.

      * Stuff to trigger runtime errors
       01 WS-CHAR-GRP-ITEM.
          05 WS-CHAR-A            PIC X(2) VALUE 'JJ'.
          05 WS-CHAR-B            PIC X(2) VALUE 'AZ'.
       01 WS-NUM-GRP-ITEM.
          05 WS-NUM-A             PIC 9(2).
          05 WS-NUM-B             PIC 9(2).
       01 WS-RESULT-ITEMS.
          05 WS-SUM-A             PIC 9(2).
          05 WS-PRD-A             PIC 9(2).

      * VARIABLES USED TO HANDLE RUN-TIME ERRORS
      * LENGTH OF THE BUFFER THAT THE SYSTEM USES AS A PARM WHILE
      * CALLING THE RUN-TIME ERROR HANDLER
       78 RTE-MSG-BUF-LEN                   VALUE 325.

      * RUN-TIME ERROR HANDLER CHAIN CONTINUE CODES - CODES THAT ALLOW
      * OR DISABLE CALLING OF OTHER RUN-TIME ERROR HANDLERS INSTALLED
      * BEFORE US.
      * RUN-TIME HANDLER CHAIN CONTINUE CODES
       78 RTEHCC-CALL-PREV-HANDLERS         VALUE 1.
       78 RTEHCC-BLOCK-PREV-HANDLERS        VALUE 0.

      * STATUS CODE RETURNED DURING THE RUN-TIME ERROR HANDLER
      * INSTALLATION TO INDICATE SUCCESS
      * RUN-TIME ERROR HANDLER INSTALLATION STATUS
       78 RTEHIS-SUCCESS                        VALUE 0.

       01 RTEH-INSTALL-FLAG                      PIC X COMP-X VALUE 0.
      * CBL-ERROR-PROC OP-CODE
          88 CEPOC-INSTALL                      VALUE 0.
          88 CEPOC-UNINSTALL                    VALUE 1.
       01 RTEH-INSTALL-ADDRESS                 USAGE PROCEDURE-POINTER.
       01 RTEH-STATUS-CODE                 PIC 9(4) COMP-5 VALUE ZEROS.
          88 RTEH-INSTALL-OK               VALUE 0.
          88 RTEH-UNINSTALL-OK             VALUE 0.

      * -------------------------------------------------------------- *

       LOCAL-STORAGE SECTION.

      * -------------------------------------------------------------- *

       LINKAGE SECTION.

      * VALUES USED TO HANDLE RUN TIME ERRORS
       01 RTE-MSG-BUF                     PIC X(RTE-MSG-BUF-LEN).

      * -------------------------------------------------------------- *

       PROCEDURE DIVISION WinAPI.

      * -------------------------------------------------------------- *
       MAIN-DRIVER.

      * Install the runtime error handler
           SET CEPOC-INSTALL TO TRUE.
           SET RTEH-INSTALL-ADDRESS TO ENTRY 'TESTCBL-RTEH'.
           CALL 'CBL_ERROR_PROC' USING RTEH-INSTALL-FLAG
                                       RTEH-INSTALL-ADDRESS
                              RETURNING RTEH-STATUS-CODE.
           IF NOT RTEH-INSTALL-OK THEN
              DISPLAY 'TESTCBL RTEH INSTALL FAILED WITH CODE ',
                                RTEH-STATUS-CODE
              GO TO MAIN-DRIVER-EXIT
           END-IF.

           DISPLAY 'TESTCBL RTEH INSTALLED'.

      * TRIGGER A RUN-TIME ERROR
           MOVE WS-CHAR-GRP-ITEM TO WS-NUM-GRP-ITEM.
           COMPUTE WS-SUM-A = WS-NUM-A + WS-NUM-B.
           COMPUTE WS-PRD-A = WS-NUM-A * WS-NUM-B.
           DISPLAY 'SUM = ', WS-SUM-A, 'PRD = ', WS-PRD-A.

      * Uninstall the runtime error handler
           SET CEPOC-UNINSTALL TO TRUE.
           SET RTEH-INSTALL-ADDRESS TO ENTRY 'TESTCBL-RTEH'.
           CALL 'CBL_ERROR_PROC' USING RTEH-INSTALL-FLAG
                                       RTEH-INSTALL-ADDRESS
                              RETURNING RTEH-STATUS-CODE.
           IF RTEH-UNINSTALL-OK THEN
              DISPLAY 'TESTCBL RTEH UNINSTALLED'
           ELSE
              DISPLAY 'TESTCBL RTEH UNINSTALL FAILED WITH CODE ',
                                RTEH-STATUS-CODE
           END-IF.

       MAIN-DRIVER-EXIT.
           EXIT PROGRAM.
           STOP RUN.

      * OUR OWN RUNTIME ERRROR HANDLER. RIGHT NOW WE JUST PRINT THE
      * THE RUNTIME ERROR AND HAND OFF THE EXECUTION TO THE HANDLER
      * NEXT IN CHAIN.
      *
       TESTCBL-RTEH-PARA.
       ENTRY 'TESTCBL-RTEH' USING RTE-MSG-BUF.

           DISPLAY 'IN TESTCBL RTEH ERR MSG = ' , RTE-MSG-BUF.
           MOVE RTEHCC-CALL-PREV-HANDLERS TO RETURN-CODE.
           EXIT PROGRAM.
           STOP RUN.
      * -------------------------------------------------------------- *



Tue, 15 Jun 1999 03:00:00 GMT  
 Run Time Error handling In MF COBOL

SNIP

Quote:
>Running testcbl via the RUN facility gives the following screen dump.

>C:\>run testcbl
>Micro Focus Object COBOL (32-bit) V4.0.16
>RUN TIME ENVIRONMENT Copyright (C) 1984-1995 Micro Focus Ltd.
>URN OXCNM/000318423

>TESTCBL RTEH INSTALLED
>IN TESTCBL RTEH ERR MSG =
>Execution error : file 'TESTCBL.int'
>error code: 163, pc=BB, call=6, seg=0
>163     Illegal character in numeric field

>Execution error : file 'TESTCBL.int'
>error code: 114, pc=BB, call=6, seg=0
>114     Attempt to access item beyond bounds of memory (Signal 11)


>(01 is zero one).

Error 163 can occur if a numeric field has been initialised with or
contains spaces, ie. move spaces to group field to clear it or
reading in a text file that has leading spaces on numeric fields.

Either correct the coding, if it is an initialisation problem, or
set runtime switch off ie (-F).

Brian

-----------------------------------------------------------
Brian W Spoor MBCS
Chartered Information Systems Practitioner
Friday Computer Software          Phone: +44-(0)1803 852625

-----------------------------------------------------------



Tue, 15 Jun 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. HELP-MF cobol run-time error 163

2. run time switches in MF cobol

3. Run Time Error Handling

4. Run Time Error Handling

5. Run-time error with Compaq Cobol v 2.7

6. Micofocus COBOL (win) run time error 166

7. DEC Ada run-time error messages (Was: More Ashamedness of Ada - this time OBJECT WORLD)

8. MF-Cobol screen-handling in Unix

9. MF Run time on AIX

10. Run Time Error - Internal Error

11. run-time error R6000 - stack overflow error

12. Graceful way to handle run-time exceptions in VSE 3.01

 

 
Powered by phpBB® Forum Software