Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

recursive activation of PERFORM -problem in Cobol

Ari_k
Occasional Advisor

recursive activation of PERFORM -problem in Cobol

Hi!

I have the following problem:

In the code I'm updating is following sections (a lot simplified):

MAIN SECTION.
MAIN_START.
...
PERFORM UNTIL ALL_FINISHED

MOVE 1 TO A_IND
PERFORM 400_GET_ROWS_FROM_TABLE

PERFORM UNTIL A_IND > ROWAMOUNT

PERFORM 600_SORT_ROWS
ADD 1 TO A_IND

END-PERFORM

END-PERFORM
...
MAIN_END.
EXIT PROGRAM.


600_SORT_ROWS SECTION.
600_SORT_ROWS_START.

...
MOVE CUSTOMERID(A_IND) TO INPUT_1
PERFORM 620_GET_COSTOMER_INFO
...
PERFORM UNTIL B_IND > CUSTOMER_RESULT_AMOUNT
IF CUSTOMER_LABEL(CUSTOMER_RESULT_AMOUNT) = 'A1' THEN...
ADD 1 TO B_IND
END-PERFORM
...


When the running of the program hits the 'perform until b_ind', the program crashes with the info below.
I have tried moving the perform in the sub-section to section of it's own, but problem stays.


%COB-F-RECACTPER, recursive activation of PERFORM
%TRACE-F-TRACEBACK, symbolic stack dump follows
image module routine line rel PC abs PC
DEC$COBRTL 0 0000000000000ECC 000000007C356ECC
Cxxx_xx_xxxxxxx_EUR Hxxx_xxxxxxxxxxx_xxxxxx_EUR Hxxx_xxxxxxxxx_xxxxxx_EUR
8387 000000000000F4D4 00000000001FEB74
Cxxx_xx_xxxxxxx_EUR Cxxx_xx_xxxxxxx_EUR Hxxx_xx_xxxxxxx_EUR
1078 0000000000002A58 00000000001D2AE8
Cxxx_xx_xxxxxxx_EUR Cxxx_xx_xxxxxxx_EUR Cxxx_xx_xxxxxxx_EUR
52 000000000000006C 00000000001D006C
Cxxx_xx_xxxxxxx_EUR 0 00000000002D971C 00000000002D971C
PTHREAD$RTL 0 0000000000055FF8 000000007BD13FF8
PTHREAD$RTL 0 0000000000030404 000000007BCEE404
0 FFFFFFFF80275EF4 FFFFFFFF80275EF4






14 REPLIES
Wim Van den Wyngaert
Honored Contributor

Re: recursive activation of PERFORM -problem in Cobol

Explanation: Attempting to PERFORM a paragraph or section
that is already activated due to a previous PERFORM
statement. This constitutes an attempted recursive
activation of the paragraph or section and is illegal in the
COBOL language. The program must execute an EXIT statement
from the paragraph or section before this paragraph or
section can be the subject of a subsequent PERFORM.

User Action: Examine the logic of the program to determine
why an EXIT from the paragraph or section is not being
executed before the subsequent PERFORM of the same paragraph
or section.
Wim
Wim Van den Wyngaert
Honored Contributor

Re: recursive activation of PERFORM -problem in Cobol

Just a wild guess because I know nothing of threads. Are you using threads with cobol ?

"the Fortran and COBOL languages are defined in such a way that compilers can make implicit use of static storage, and such compilers do not generate reentrant code; it is difficult to write reentrant code in a nonreentrant language".

If not, post versions of vms, cobol and a complete source listing.

Wim
Wim
Ari_k
Occasional Advisor

Re: recursive activation of PERFORM -problem in Cobol

Hi,

I have examined the logic of the program for the last 1,5 days now :-) trying to solve this.

System: XMA97, AlphaServer ES45 Model 2B
Cobol : OpenVMS V7.3-2

Marc Van den Broeck
Trusted Contributor

Re: recursive activation of PERFORM -problem in Cobol

Ari,

within the 'unlabeled' perform until a_ind,
you perform the section 600_sort_rows and in
this section you do another 'unlabeled' perform until b_ind.

I guess you cant nest 'unlabeled' performs. So, try to make the perform until b_ind a 'named' perform.

Rgds
Marc
Ari_k
Occasional Advisor

Re: recursive activation of PERFORM -problem in Cobol

Hi,

I forgot to mention that we are not using threads.

Spent this morning sitting next to the local guru, and we arrived to the conclusion, that the problem is most likely in the subprogram in section 620_GET_COSTOMER_INFO. Maybe the object isn't linked ok or is old, or maybe has some undiscovered problems (legacy code, old as ...).

Thank you for your quick replies, I found this forum only today and this seems the place to read to learn more! I'll see now if the subprogram is the cause of all this.
Ari_k
Occasional Advisor

Re: recursive activation of PERFORM -problem in Cobol

Hi again,

The subprogram is 'giving out' info in 50-size array, and the receiving end was defined to accept only 30. So the extra 20 dissapered into the memory somewhere and caused a bit erratic problems. At least, that's what I'm thinking now.
Ari_k
Occasional Advisor

Re: recursive activation of PERFORM -problem in Cobol

I believe we have found the culprit for the problems and can now fix it.
Hein van den Heuvel
Honored Contributor

Re: recursive activation of PERFORM -problem in Cobol


Looks to me like that is a bad program end.

Cobol is (documented!) to ignore that EXIT PROGRAM. Odd and dispicable behaviour in my book, but that's how it is supposed to be.

Change to STOP RUN and try again:

The (uncontrolled) entry into the 600_SORT_ROWS SECTION can lead to anything.

IDENTIFICATION DIVISION.
PROGRAM-ID. my-test.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 RETURN_VAR PIC S9(9) USAGE IS COMP.
PROCEDURE DIVISION.
MY_MAIN SECTION.
MAIN.
PERFORM 600_SORT_ROWS.
DISPLAY "Main done.".
MAIN_END.
EXIT PROGRAM.
DISPLAY "Can not get here?".
600_SORT_ROWS SECTION.
600_SORT_ROWS_START.
DISPLAY "Sort done.".
600_SORT_ROWS_END.

$ cob tmp
$ link tmp
$ run tmp
Sort done.
Main done.
Can not get here?
Sort done.


Hein.
Ari_k
Occasional Advisor

Re: recursive activation of PERFORM -problem in Cobol

Hi,

We have been ordered to use STOP RUN only in the end of the main prog, and to use EXIT PROGRAM in all modules below.

Anyway, I fixed the problem; my settings were a bit off, so the new, updated subprogram's libraries weren't copied correctly to this module, but were correctly used in the obj of the subprogram which resulted an data overflow.

Thanks again, you all brought light to darkness at very crucial moment ;-)

(Sorry for my undiciplined use of English and especially correct terminology, English is my 3rd language.)

Hein van den Heuvel
Honored Contributor

Re: recursive activation of PERFORM -problem in Cobol

>> We have been ordered to use STOP RUN only in the end of the main prog, and to use EXIT PROGRAM in all modules below.

Please forward to "Dilbert". It's worthy.

In the light of my example above, do you still think that management edict is prudent and worth following?

Best regards,
Hein
Wim Van den Wyngaert
Honored Contributor

Re: recursive activation of PERFORM -problem in Cobol

Hein,

I think this is a subroutine. And then EXIT PROGRAM is ok. Only the master program must do STOP RUN.

Wim
Wim
Ari_k
Occasional Advisor

Re: recursive activation of PERFORM -problem in Cobol


Exactly, thanks Wim!
Hein van den Heuvel
Honored Contributor

Re: recursive activation of PERFORM -problem in Cobol

Drats. My physic powers must be on the wane.

Or maybe it is the fact the the word 'subroutine' was never used. Only comments like. "running of the program ", "I have examined the logic of the program".

But anyway, Absolutely, 'exit program' is just fine for a subroutine, and 'stop run' is rarely appropriate for a subroutine.

Cheers!

Hein.


Ari_k
Occasional Advisor

Re: recursive activation of PERFORM -problem in Cobol

Yeah, sorry about that... I was painfully aware that my terminology was substandard.

Anyway, I fixed the settings so that the code for subroutine in 620_GET_COSTOMER_INFO, just above the place where the errorcode happened, was linked from the right source and the sun was shining again.

Once again, thanks to everyone!