ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

User Space Issue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • User Space Issue

    I am writing a program that creates a user space and then loads it with records from a file that I read. This program used to work several years ago but now I am getting "Space offset X'40404040' or X'0000000000000000' is outside current limit" errors. I am wondering if something has changed in some of the newer releases. We now have V7R2. I have attached part of the code. The line where the error occurred is highlighted. I noticed that when I put it in debug, the values in uOffSetToList, uNumOfEntrys , and uSizeOfEntry are all the same and very large (1077952576), It creates the user space OK but when it assigns the value of the pointer to the user space to the pointer to data structure ListInfoDS is when it aborts
    Attached Files

  • #2
    I think I see the problem, it looks like I am not giving the user space an initial size when I create it

    Comment


    • #3
      The user space is being created with blanks (x'40') as the data (SpaceValue 1A has a default initialization value of blank, x'40').

      You are using uOffSetToList immediately after creating the user space, so it is expected that it would contain x'40404040' (1,077,952,576).
      Code:
      PointerName = CrtUsrSpc(UserSpace);
         Exsr LoadUsrSpc;
         ...
      
      Begsr LoadUsrSpc;
         ListPointer = PointerName + uOffSetToList;
      I wonder if the user space already existed on your previous system. If it did already exist, then the header might have been set up correctly already.

      From what you've showed us, I think your code to create the user space would run without error if the user space already existed.

      Your call to QUSCRTUS has QUSEC in the error-code parameter. From the code you showed us, the QUSBPRV (bytes provided) subfield of QUSEC isn't set, so that would also be x'40404040', greater than zero, so the API would put error information about the user space already existing into QUSEC, rather than issuing an exception.

      If your code isn't setting QUSBPRV, then you have a potential storage corruption problem. With a bytes-provided value of over a billion, QUSCRTUS would be free to update that many bytes of the error code parameter. If it updated more than the size of QUSEC, it would corrupt whatever variables happened to follow QUSEC in storage.

      So you should set QUSBPRV to %SIZE(QUSEC). And then you should probably check QUSEC after the call, to make sure that any error you get is an expected error.

      Comment


      • #4
        Originally posted by gregwga50 View Post
        I think I see the problem, it looks like I am not giving the user space an initial size when I create it
        I think the SpaceLen parameter is the initial size (4096). The call to QUSCUSAT makes the space auto-extendable, which means you can refer to storage up to the maximum size of a user space, around 16 million (much smaller than the 1 billion your code trying to do).

        Comment


        • #5
          The user space is being created with blanks (x'40') as the data (SpaceValue 1A has a default initialization value of blank, x'40').
          I changed SpaceValue to x'00' (I saw this in another example somewhere) and I did not get the error I got previously

          You are using uOffSetToList immediately after creating the user space, so it is expected that it would contain x'40404040' (1,077,952,576).
          I copied my program from another program that calls an IBM API to populate the user space. Since I am not doing this in this program, I figure I can start loading the user space from the beginning instead of calculating an offset to start from.

          So you should set QUSBPRV to %SIZE(QUSEC). And then you should probably check QUSEC after the call, to make sure that any error you get is an expected error.
          I will make this change

          maximum size of a user space, around 16 million (much smaller than the 1 billion your code trying to do).
          Just curious how you figure 1 billion my code is trying to use.

          Thanks so much for your help. Your responses are always very helpful


          Comment


          • #6
            Originally posted by gregwga50 View Post
            Just curious how you figure 1 billion my code is trying to use.
            Actually, it's a little over one billion. The value x'40404040' is 1,077,952,576.

            Comment


            • #7
              Originally posted by Barbara Morris View Post

              Actually, it's a little over one billion. The value x'40404040' is 1,077,952,576.

              So, it's because I have x'40404040' or (1,077,952,576) in the uOffsetToList, correct? Just trying to understand. I took that out of my code.

              Comment


              • #8
                Originally posted by gregwga50 View Post


                So, it's because I have x'40404040' or (1,077,952,576) in the uOffsetToList, correct? Just trying to understand. I took that out of my code.
                Correct. Now that you have x'00' as the initial value, any integer fields defined in a data structure based on the user space pointer will have zero immediately after the user space is created.

                Comment

                Working...
                X