what will happen if max range of loop is junk?

IBM's cross-platform compiler PL/I for MVS, VM & VSE, OS/390 and Enterprise PL/I for z/OS
apjohn1986
Posts: 16
Joined: Mon Jan 31, 2011 12:26 pm
Skillset: beginner
Referer: friend

what will happen if max range of loop is junk?

Postby apjohn1986 » Tue May 23, 2017 5:18 pm

One PL1 program is failing due to infinite looping. It seems like the max range is not set properly. What will happen if x has junk values in the below code? program will abend (S0C7) when value moved to x or infinite loop?

x = <value returned from another module>;
Do i = 1 to x WHILE(a = b);
...
end;
Thanks,
John

User avatar
Akatsukami
Global moderator
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Skillset: Rexx, JCL, DB2/SQL, TSO/ISPF, PL/I
Referer: ibmmainframes
Location: Bloomington, IL
Contact:

Re: what will happen if max range of loop is junk?

Postby Akatsukami » Tue May 23, 2017 5:44 pm

A S0C1 or S0C4 abends (translated to oncodes 8091 or 8094) are likely; the program may overwrite code with data (causing a S0C1) or address storage not belonging to the enclave. Other S0Cx abends are possible, including S0C7 (I once got a S0C6), but are considerably less likely than S0C1/4.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day

User avatar
prino
Posts: 641
Joined: Wed Mar 11, 2009 12:22 am
Skillset: PL/I - CICS - DB2 - IDMS - REXX - JCL, most in excess of three decades
Referer: Google
Location: Vilnius, Lithuania
Contact:

Re: what will happen if max range of loop is junk?

Postby prino » Tue May 23, 2017 6:03 pm

apjohn1986 wrote:One PL1 program is failing due to infinite looping. It seems like the max range is not set properly. What will happen if x has junk values in the below code? program will abend (S0C7) when value moved to x or infinite loop?

x = <value returned from another module>;
Do i = 1 to x WHILE(a = b);
...
end;

Give the declares of i and x, without those there is no way of telling what would happen. And for what it's worth infinite, loops can only occur if i

  • is declared as PIC 'whatever' (And if you use PIC variables in loops you deserve what you get :mrgreen: ), or
  • you modify i inside the loop (and then you also deserve what you get :mrgreen: )
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy

apjohn1986
Posts: 16
Joined: Mon Jan 31, 2011 12:26 pm
Skillset: beginner
Referer: friend

Re: what will happen if max range of loop is junk?

Postby apjohn1986 » Tue May 23, 2017 8:04 pm

i is bin(15) and x is fixed bin(31)

There is no increment of i inside loop
Thanks,
John

User avatar
prino
Posts: 641
Joined: Wed Mar 11, 2009 12:22 am
Skillset: PL/I - CICS - DB2 - IDMS - REXX - JCL, most in excess of three decades
Referer: Google
Location: Vilnius, Lithuania
Contact:

Re: what will happen if max range of loop is junk?

Postby prino » Wed May 24, 2017 12:39 am

apjohn1986 wrote:i is bin(15) and x is fixed bin(31)

Sigh...

And you still don't realize what's wrong...
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy

apjohn1986
Posts: 16
Joined: Mon Jan 31, 2011 12:26 pm
Skillset: beginner
Referer: friend

Re: what will happen if max range of loop is junk?

Postby apjohn1986 » Wed May 24, 2017 7:52 am

What's wrong?

This is working fine if value from sub module is valid. question is what if that's junk
Thanks,
John

User avatar
Akatsukami
Global moderator
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Skillset: Rexx, JCL, DB2/SQL, TSO/ISPF, PL/I
Referer: ibmmainframes
Location: Bloomington, IL
Contact:

Re: what will happen if max range of loop is junk?

Postby Akatsukami » Wed May 24, 2017 8:03 am

What will happen if the value of x is greater than 32,767?
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day

apjohn1986
Posts: 16
Joined: Mon Jan 31, 2011 12:26 pm
Skillset: beginner
Referer: friend

Re: what will happen if max range of loop is junk?

Postby apjohn1986 » Wed May 24, 2017 8:37 am

Yeah got the point.

But there is a correction in my previous statement. x is bin(15) only, the field assign value to it is fixed bin(31)
Thanks,
John

User avatar
Akatsukami
Global moderator
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Skillset: Rexx, JCL, DB2/SQL, TSO/ISPF, PL/I
Referer: ibmmainframes
Location: Bloomington, IL
Contact:

Re: what will happen if max range of loop is junk?

Postby Akatsukami » Wed May 24, 2017 8:49 am

So then the first two bytes of the transmitting field will be truncated, yes? Of course the truncated value will be valid -- every bit pattern in a 2s-complement binary variable is a valid number -- but it will be incorrect. However, since the value is valid, there will be no problem with the DO loop.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day


  • Similar Topics
    Replies
    Views
    Last post