Subscript range error

Figure 1 illustrates an error caused by an array subscript value outside the declared range. In this example, the declared array value is 10. This routine was compiled with the options LIST, TEST, GONUMBER, and MAP. It was run with the TERMTHDACT(TRACE) option to generate a traceback for the condition.

Figure 1. Example of moving a value outside an array range (Enterprise PL/I)
5655-H31  IBM(R) Enterprise PL/I for z/OS       V3.R6.M0 (Built:20070119)                      2007.01.31 15:59:36   Page     1     
                     Options Specified                                                                                              
  Install:                                                                                                                          
  Command:                                                                                                                          
  Line.File Process Statements                                                                                                      
     1.0    *PROCESS  GONUMBER LIST S STG TEST MAP;                                                                                 
  Install:                                                                                                                          
5655-H31  IBM(R) Enterprise PL/I for z/OS       EXAMPLE:  PROC  OPTIONS(M                      2007.01.31 15:59:36   Page     2     
 Compiler Source                                                                                                                    
    Line.File                                                                                                                       
       2.0      EXAMPLE:  PROC  OPTIONS(MAIN);                                                                                      
       3.0                                                                                                                          
       4.0          DCL Array(10) Fixed bin(31);                                                                                    
       5.0          DCL (I,Array_End)   Fixed bin(31);                                                                              
       6.0          On error                                                                                                        
       7.0            Begin;                                                                                                        
       8.0              On error system;                                                                                            
       9.0              Call plidump('tbnfs','Plidump called from error On-unit');                                                  
      10.0            End;                                                                                                          
      11.0                                                                                                                          
      12.0          (subrg):              /* Enable subscriptrange condition */                                                     
      13.0          Labl1: Begin;                                                                                                   
      14.0            Array_End = 20;                                                                                               
      15.0            Do I = 1 to Array_End;   /* Loop to initialize array */                                                       
      16.0              Array(I) = 2;    /* Set array elements to 2 */                                                              
      17.0            End;                                                                                                          
      18.0          End Labl1;                                                                                                      
      19.0       End Example;                                                                                                       
5655-H31  IBM(R) Enterprise PL/I for z/OS       EXAMPLE:  PROC  OPTIONS(M                      2007.01.31 15:59:36   Page     3     
                     Block Name List                                                                                                
    Number  Name                                                                                                                    
         1  EXAMPLE                                                                                                                 
         2  _ON_Begin_7_Blk_2                                                                                                       
         3  _Begin_12_Blk_3                                                                                                         
5655-H31  IBM(R) Enterprise PL/I for z/OS       EXAMPLE:  PROC  OPTIONS(M                      2007.01.31 15:59:36   Page     4     
                                                                                                                                    
OFFSET OBJECT CODE        LINE#  FILE#    P S E U D O   A S S E M B L Y   L I S T I N G                                             
                                                                                                                                    
                          Timestamp and Version Information                                                                         
000000  F2F0  F0F7                                       =C'2007'           Compiled Year                                           
000004  F0F1  F3F1                                       =C'0131'           Compiled Date MMDD                                      
000008  F1F5  F5F9  F3F6                                 =C'155936'         Compiled Time HHMMSS                                    
00000E  F0F3  F0F6  F0F0                                 =C'030600'         Compiler Version                                        
                                                                                                                                    
000014  0036  ****                                       Service String     20070122                                                
                          Timestamp and Version End                                                                                 
                                                                                                                                    
5655-H31  IBM(R) Enterprise PL/I for z/OS       EXAMPLE:  PROC  OPTIONS(M  : _Begin_12_Blk_3   2007.01.31 15:59:36   Page     5     
                                                                                                                                    
OFFSET OBJECT CODE        LINE#  FILE#    P S E U D O   A S S E M B L Y   L I S T I N G                                             
                                                                                                                                    
⋮                                                                                                                                   
5655-H31  IBM(R) Enterprise PL/I for z/OS       EXAMPLE:  PROC  OPTIONS(M                      2007.01.31 15:59:36   Page    17     
                                                                                                                                    
                               * * * * *   S T O R A G E   O F F S E T   L I S T I N G   * * * * *                                  
                                                                                                                                    
IDENTIFIER          DEFINITION      ATTRIBUTES                                                                                      
                                    <SEQNBR>-<FILE NO="">:<FILE LINE="">                                                               
                                                                                                                                    
ARRAY               1-0:4           Class = automatic,           Location = 192 : 0xC0(r13),                   Length = 40          
                                                                                                                                    
ARRAY_END           1-0:5           Class = automatic,           Location = 236 : 0xEC(r13),                   Length = 4           
                                                                                                                                    
I                   1-0:5           Class = automatic,           Location = 232 : 0xE8(r13),                   Length = 4           
                                                                                                                                    
                         * * * * *   E N D   O F   S T O R A G E   O F F S E T   L I S T I N G   * * * * *                          
⋮  

Figure 2 shows sections of the dump generated by a call to PLIDUMP.

Figure 2. Sections of the Language Environment dump (Part 1 of 2)
CEE3DMP V1 R9.0: Plidump called from error On-unit                                 01/31/07 3:59:39 PM                  Page:    1  
ASID: 010E   Job ID: J0009410   Job name: LEDGSMP1   Step name: GO         UserID: BARBARA                                          
                                                                                                                                    
CEE3845I CEEDUMP Processing started.                                                                                                
PLIDUMP was called from statement number 9 at offset +000000D2 from _ON_Begin_7_Blk_2 with entry address 11200240                   
                                                                                                                                    
Information for enclave EXAMPLE                                                                                                     
                                                                                                                                    
  Information for thread 8000000000000000                                                                                           
                                                                                                                                    
  Traceback:                                                                                                                        
    DSA   Entry       E  Offset  Statement   Load Mod             Program Unit                   Service  Status                    
    1     IBMPDUMP    +000002AE              IBMPEV11                                            PQ78306  Call                      
    2     _ON_Begin_7_Blk_2                                                                                                         
                      +000000D2  9           EXAMPLE              _Begin_12_Blk_3                         Call                      
    3     IBMPEONR    +000002A2              IBMPEV11                                            PQ76426  Call                      
    4     IBMPEBOP    +000004DC              IBMPEV11                                            LE19BAS  Call                      
    5     CEEEV011    +00000132              IBMPEV11             CEEEV011                                Call                      
    6     CEEHDSP     +000017D0              CEEPLPKA             CEEHDSP                        D1908    Call                      
    7     IBMBERRI    +000000AA              IBMPEV11                                            LE19BAS  Exception                 
    8     ERR_RAISE_COND                                                                                                            
                      +00000090              IBMPEV11                                            LE19BAS  Call                      
    9     IBMPERSU    +00000082              IBMPEV11                                            LE19BAS  Call                      
    10    _Begin_12_Blk_3                                                                                                           
                      +00000100  16          EXAMPLE              _Begin_12_Blk_3                         Call                      
    11    EXAMPLE     +000000B0  12          EXAMPLE              _Begin_12_Blk_3                         Call                      
    12    IBMPMINV    +000004DE              IBMPEV11             IBMPMINV                                Call                      
    13    CEEEV011    +00000202              IBMPEV11             CEEEV011                                Call                      
    14    CEEBBEXT    +000001B6              CEEPLPKA             CEEBBEXT                       D1908    Call                      
                                                                                                                                    
    DSA   DSA Addr   E  Addr    PU Addr    PU Offset  Comp Date  Compile Attributes                                                 
    1     11A3DE50   114A4E38   114A4E38   +000002AE  20061214   LIBRARY   EBCDIC  HFP                                              
    2     11A3DD70   11200240   112000D0   +00000242  20070131   ENT PL/I EBCDIC  HFP                                               
    3     11A3DBD8   114A7B98   114A7B98   +000002A2  20061214   LIBRARY   EBCDIC  HFP                                              
    4     11A3DA08   114AF390   114AF390   +000004DC  20061214   LIBRARY   EBCDIC  HFP                                              
    5     11A3D978   114062E8   114062E8   +00000132  20061214   LIBRARY                                                            
    6     11A3A858   112C3238   112C3238   +000017D0  20061215   CEL                                                                
    7     11A3A6B8   114AAA18   114AAA18   +000000AA  20061214   LIBRARY   EBCDIC  HFP                                              
    8     11A3A618   114A9FA8   114A9FA8   +00000090  20061214   LIBRARY   EBCDIC  HFP                                              
    9     11A3A570   114AB120   114AB120   +00000082  20061214   LIBRARY   EBCDIC  HFP                                              
    10    11A3A4A8   112000D0   112000D0   +00000100  20070131   ENT PL/I EBCDIC  HFP                                               
    11    11A3A3B8   11200340   112000D0   +00000320  20070131   ENT PL/I EBCDIC  HFP                                               
    12    11A3A180   114DD990   114DD990   +000004DE  20061214   LIBRARY                                                            
    13    11A3A0F0   114062E8   114062E8   +00000202  20061214   LIBRARY                                                            
    14    11A3A030   11291208   11291208   +000001B6  20061215   CEL                                                                
                                                                                                                                    
  Condition Information for Active Routines                                                                                         
    Condition Information for  (DSA address 11A3A6B8)                                                                               
      CIB Address: 11A3B178                                                                                                         
      Current Condition:                                                                                                            
        IBM0281S A prior condition was promoted to the ERROR condition.                                                             
      Original Condition:                                                                                                           
        IBM0421S  ONCODE=520  The SUBSCRIPTRANGE condition was raised.                                                              
      Location:                                                                                                                     
        Program Unit:  Entry: IBMBERRI Statement:  Offset: +000000AA                                                                
                                                                                                                                    
    Storage dump near condition, beginning at location: 114AAAB2                                                                    
      +000000 114AAAB2  4110D098 5050D098 5040D09C 5040D0A0  05EF1F00 43002016 A7010080 A7840009  |...q&&.q& ..& ..........x...xd..|
                                                                                                                                    
                                                                                                                                    
CEE3DMP V1 R9.0: Plidump called from error On-unit                                 01/31/07 3:59:39 PM                  Page:    2  
ASID: 010E   Job ID: J0009410   Job name: LEDGSMP1   Step name: GO         UserID: BARBARA                                          
                                                                                                                                    
  Control Blocks for Active Routines:                                                                                               
    DSA for IBMPDUMP: 11A3DE50                                                                                                      
      +000000  FLAGS.... 1000      member... 0000      BKC...... 11A3DD70  FWC...... 11A3E150  R14...... 914A50E8                   
      +000010  R15...... 912EF898  R0....... 00000000  R1....... 11A3DEE8  R2....... 00000002  R3....... 114A5104                   
      +000024  R4....... 11A3DEFC  R5....... 11A3E04C  R6....... 11200800  R7....... 11200438  R8....... 11A3B264                   
      +000038  R9....... 00000014  R10...... 00000098  R11...... 11A3A468  R12...... 112129B0  reserved. 00000000                   
      +00004C  NAB...... 11A3E150  PNAB..... 00000000  reserved. 00000000  11A3DB34                                                 
      +000064  reserved. 926DF340  reserved. 81A340A2  MODE..... A381A385  reserved. 948595A3                                       
      +000078  reserved. 81A34083  reserved. C6C5D5E4                                                                               
    Dynamic save area (IBMPDUMP): 11A3DE50                                                                                          
      +000000 11A3DE50  10000000 11A3DD70 11A3E150 914A50E8  912EF898 00000000 11A3DEE8 00000002  |.....t...t.&j.&Yj.8q.....t.Y....|
      +000020 11A3DE70  114A5104 11A3DEFC 11A3E04C 11200800  11200438 11A3B264 00000014 00000098  |.....t...t.<.........t.........q|
      +000040 11A3DE90  11A3A468 112129B0 00000000 11A3E150  00000000 00000000 11A37B2E 11A3DB34  |.tu..........t.&.........t#..t..|
⋮             
Figure 3. Sections of the Language Environment dump (Part 2 of 2)
    DSA for _Begin_12_Blk_3: 11A3A4A8                                                                                               
      +000000  FLAGS.... 1000      member... 0000      BKC...... 11A3A3B8  FWC...... 11A3A7D8  R14...... 912001D2                   
      +000010  R15...... 914AB120  R0....... 0000000A  R1....... 11A3A478  R2....... 0000000B  R3....... 1120010A                   
      +000024  R4....... 11A3A0D8  R5....... 11A3A3B8  R6....... 11200800  R7....... 00000000  R8....... 11211648                   
      +000038  R9....... 00000008  R10...... 11A3A0B0  R11...... 11200ACC  R12...... 112129B0  reserved. 00000000                   
      +00004C  NAB...... 11A3A570  PNAB..... 00000000  reserved. 00000000  00000000                                                 
      +000064  reserved. 00000000  reserved. 00000000  MODE..... 00000000  reserved. 00000000                                       
      +000078  reserved. 00000000  reserved. 00000000                                                                               
    Dynamic save area (_Begin_12_Blk_3): 11A3A4A8                                                                                   
      +000000 11A3A4A8  10000000 11A3A3B8 11A3A7D8 912001D2  914AB120 0000000A 11A3A478 0000000B  |.....tt..txQj..Kj........tu.....|
      +000020 11A3A4C8  1120010A 11A3A0D8 11A3A3B8 11200800  00000000 11211648 00000008 11A3A0B0  |.....t.Q.tt..................t..|
      +000040 11A3A4E8  11200ACC 112129B0 00000000 11A3A570  00000000 00000000 00000000 00000000  |.............tv.................|
      +000060 11A3A508  00000000 00000000 00000000 00000000  00000000 00000000 00000000 00000000  |................................|
      +000080 11A3A528  11A3A120 9129B186 11A3A0F0 00000000  10A3A0F0 11A3A4A8 00000000 00000000  |.t..j..f.t.0.....t.0.tuy........|
      +0000A0 11A3A548  00180280 11A3A4A8 11A3A450 11200A00  00000014 11A3A3B8 0000000A 0000000B  |.....tuy.tu&.........tt.........|
      +0000C0 11A3A568  11A3A478 11200340 10A3A4A8 11A3A4A8  11200650 914AB1A4 114A9FA8 00000020  |.tu.... .tuy.tuy...&j..u...y....|
    DSA for EXAMPLE: 11A3A3B8                                                                                                       
      +000000  FLAGS.... 10A3      member... A12C      BKC...... 11A3A180  FWC...... 11A3A138  R14...... 912003F2                   
      +000010  R15...... 112000D0  R0....... 11A3A3B8  R1....... 11200240  R2....... 11211768  R3....... 1120037A                   
      +000024  R4....... 11A3A0D8  R5....... 11A3A3B8  R6....... 11200800  R7....... 00000000  R8....... 11211648                   
      +000038  R9....... 00000008  R10...... 11A3A0B0  R11...... 11200ACC  R12...... 112129B0  reserved. 00000000                   
      +00004C  NAB...... 11A3A4A8  PNAB..... 00000000  reserved. 00000000  00000000                                                 
      +000064  reserved. 00000000  reserved. 00000000  MODE..... 00000000  reserved. 00000000                                       
      +000078  reserved. 00000000  reserved. 00000000                                                                               
    Dynamic save area (EXAMPLE): 11A3A3B8                                                                                           
      +000000 11A3A3B8  10A3A12C 11A3A180 11A3A138 912003F2  112000D0 11A3A3B8 11200240 11211768  |.t...t...t..j..2.....tt.... ....|
      +000020 11A3A3D8  1120037A 11A3A0D8 11A3A3B8 11200800  00000000 11211648 00000008 11A3A0B0  |...:.t.Q.tt..................t..|
      +000040 11A3A3F8  11200ACC 112129B0 00000000 11A3A4A8  00000000 00000000 00000000 00000000  |.............tuy................|
      +000060 11A3A418  00000000 00000000 00000000 00000000  00000000 00000000 00000000 00000000  |................................|
      +000080 11A3A438  00000000 00000000 00000000 00000000  00000000 00000000 00100000 00000000  |................................|
      +0000A0 11A3A458  00180180 11A3A3B8 00000000 11200980  0B300000 11200240 11A3A3B8 00000000  |.....tt................ .tt.....|
      +0000C0 11A3A478  00000002 00000002 00000002 00000002  00000002 00000002 00000002 00000002  |................................|
      +0000E0 11A3A498  00000002 00000002 0000000B 00000014  10000000 11A3A3B8 11A3A7D8 912001D2  |.....................tt..txQj..K|
    ENTERPRISE PL/I OPTIONS:                                                                                                        
     AFP, ARCH( 5), BACKREG(5), BIFPREC(15), CHECK(NOCONFORMANCE, NOSTORAGE), CMPAT(V2), CODEPAGE( 1140), COMMON,                   
     NOCOMPACT, CSECT, CSECTCUT( 4) CURRENCY( $), NODBCS, DECIMAL( FOFLONASGN, NOFORCEDSIGN), DEFAULT( IBM, ASSIGNABLE,             
     NOINITFILL, NONCONNECTED, DESCRIPTOR, DESCLOCATOR, DUMMY(ALIGNED), ORDINAL(MIN), BYADDR, RETURNS(BYADDR),                      
     LINKAGE(OPTLINK), NORETCODE, NOINLINE, ORDER, NOOVERLAP, NONRECURSIVE, ALIGNED, NULL370, EVENDEC, SHORT(HEXADEC),              
     EBCDIC, HEXADEC, NATIVE, NATIVEADDR, E(HEXADEC) ), DISPLAY(WTO), NODLLINIT, EXTRN(FULL), NOGRAPHIC, NOINITAUTO,                
     NOINITBASED, NOINITCTL, NOINITSTATIC, NOINTERRUPT, LIMITS( EXTNAME( 7), FIXEDBIN( 31, 31), FIXEDDEC( 15, 15), NAME( 100        
     )), OPTIMIZE( 0), PREFIX( CONVERSION, FIXEDOVERFLOW, INVALIDOP, OVERFLOW, PRECTYPE(ANS), NOSIZE, NOSTRINGRANGE,                
     NOSTRINGSIZE, NOSUBSCRIPTRANGE, UNDERFLOW, ZERODIVIDE), REDUCE, NORENT, RESEXP, RESPECT(), RULES(IBM), NOSTDSYS,               
     NOSCHEDULER, STRINGOFGRAPHIC(GRAPHIC), SYSTEM(MVS), TEST(ALL ,SYM ,HOOK ,NOSEPARATE), TUNE( 5), USAGE( ROUND(IBM),             
     UNSPEC(IBM)), WIDECHAR(BIGENDIAN), WINDOW( 1950), WRITABLE, XINFO(NODEF, NOXML)                                                
    Static for procedure EXAMPLE    Timestamp: 2007.01.31 15:59:36 V03.R06.M00: 11200800                                            
      +000000 11200800  02020240 00000005 02020240 00000021  00000000 11200898 00000000 11200830  |... ....... ...........q........|
      +000020 11200820  00000000 11200898 00000000 11200830  00000000 11200838 00000000 00000000  |.......q........................|
      +000040 11200840  31010001 00000000 00000000 00000000  00000010 00000000 00000000 00000000  |................................|
      +000060 11200860  112008B0 00000000 00000000 00000000  00000004 00000004 0000000A 00000001  |................................|
      +000080 11200880  0000001B 00000024 0000002D 00000032  00000000 00000000 112008D0 112008F0  |...............................0|
      +0000A0 112008A0  11200910 11200930 00000000 11200860  02002200 11200340 00000000 00000000  |...............-....... ........|
      +0000C0 112008C0  11200840 11200438 00090107 00000000  42002201 000000A2 00000000 00000000  |... ...................s........|
      +0000E0 112008E0  30000000 11200444 00090105 00000000  48012401 D00000C0 11200870 00000000  |................................|
      +000100 11200900  00001F80 1120044C 00010105 00000000  40002401 D00000E8 00000000 00000000  |.......<........ ......Y........|
      +000120 11200920  00001F80 11200454 00010101 00000000  40002401 D00000EC 00000000 00000000  |................ ...............|
      +000140 11200940  00001F80 11200458 00010109 00000000  00000003 00000010 00000002 0000002D  |................................|
      +000160 11200960  00000024 0000000F 00000002 0000002D  00000032 0000000E 00000001 00000032  |................................|
      +000180 11200980  D0000098 00100000 6E3BFFE0 00000000  11200898 11200A80 11200830 90010000  |...q....>..........q............|
      +0001A0 112009A0  11200340 00000000 00000000 00000004  11200880 00000000 112009C0 00000000  |... ............................|
      +0001C0 112009C0  D00000A8 00100000 6E3BFFE0 00000000  11200820 11200A80 11200828 83010000  |...y....>...................c...|
      +0001E0 112009E0  11200240 11200980 11200A00 00000000  00000000 00000000 00000000 00000000  |... ............................|
      +000200 11200A00  D0000098 00000000 6E7BFFE0 00000000  11200810 11200A80 11200818 01000000  |...q....>#......................|
      +000220 11200A20  112000D0 11200980 00000000 00000000  00000000 11200950 00000000 00000000  |.......................&........|
      +000240 11200A40  00000000 00000000 00000000 00000000  00010007 C5E7C1D4 D7D3C500 010005D3  |....................EXAMPLE....L|
      +000260 11200A60  C1C2D3F1 00010005 C1D9D9C1 E8000100  01C90001 0009C1D9 D9C1E86D C5D5C400  |ABL1....ARRAY....I....ARRAY_END.|
      +000280 11200A80  00000000 11200464 E1100FF2 F0F0F7F0  F1F3F1F1 F5F5F9F3 F6F0F0F0 0000003F  |...........20070131155936000....|
      +0002A0 11200AA0  11200A40 11200860 11200838 00000001  11200850 00220000 00000000 11200980  |... ...-...........&............|
      +0002C0 11200AC0  11200438 00000000 01000001 11200340  11200FC0 00000000 18AF47F0 A016C3C5  |............... ...........0..CE|
⋮

To debug this routine, use the following steps:

  1. In the dump, PLIDUMP was called by the ERROR ON-unit in statement 9. The traceback information in the dump shows that the exception occurred following statement 16.
    Note: In the Language Environment® dumps, the columns and messages refer to "statements", but the numbers are actually (for Enterprise PL/I) the line numbers from the source file.
  2. Locate the Original Condition message in the Condition Information for Active Routines section of the dump.The message is IBM0421S ONCODE=520 The SUBSCRIPTRANGE condition was raised. This message indicates that the exception occurred when an array element value exceeded the subscript range value (in this case, 10). For more information about this message, see z/OS Language Environment Runtime Messages.
  3. Locate statement 14 in the routine in Figure 1. The instruction is Array_End = 20. This statement assigns a 20 value to the variable Array_End.
  4. Statement 15 begins the DO-loop instruction Do I = 1 to Array_End. Since the previous instruction (statement 14) specified that Array_End = 20, the loop in statement 10 should run until I reaches a 20 value.

    The instruction in statement 4, however, declared a 10 value for the array range. Therefore, when the I value reached 11, the SUBSCRIPTRANGE condition was raised.

The following steps provide another method for finding the value that raised the SUBSCRIPTRANGE condition.

  1. Locate the offset of variable I in the storage offset listing in Figure 1. Use this offset to find the I value at the time of the dump. In this example, the offset is X'E8'.
  2. Now find offset X'E8' from the start of the stack frame for the entry EXAMPLE in Figure 2.

    The block located at this offset contains the value that exceeded the array range, X'B' or 11.