IBM Support

LI76228: INCORRECT OFFSET IN PROG WITH LARGE STACK

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The following test case produces an illegal instruction when
    compiled in 64 bit mode.
    
    ====Compile Command:
    cc -qlargetype -bmaxstack:0xA0000000 -q64  -qlist test.c
    
    ====Testcase:
    $cat test.c
     #include <stdio.h>
     #include <procinfo.h>
    
     #include <unistd.h>
    
    struct sub_test{
    int num;
    char CC[3];
    char AA[500];
    char BB[3];
    };
    
    struct St_test{
    int AA;
    char BB[3];
    char CC[100];
    struct sub_test subtest[1105];
    };
    
    struct St_test STTest[300];
    
    void init()
    {
    
     for(int i=0; i<100; i++)
    {
       STTest[i].AA=i;
        strcpy(STTest[i].BB,"aa");
       strcpy(STTest[i].CC,
    "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
    ccccccccccccccccccc");
      for(int j=0;j<600;j++)
      {
        STTest[i].subtest[j].num=j;
    
    strcpy(STTest[i].subtest[j].AA,"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    );
        strcpy(STTest[i].subtest[j].BB,"1");
        strcpy(STTest[i].subtest[j].CC,"cc");
     }
    }
    
    }
    
     void getallproc(struct St_test *test)
     {
        char args[25];
    
      struct St_test  tests;
       tests.AA=1;
       strcpy(tests.BB,"1");
       strcpy(tests.CC,"2");
       *test=tests;
      strcpy(test->subtest[100].AA,"20");
      for(int i=0;i<100;i++)
       {
           if(STTest[i].AA==90)
           {
       printf("CC:%s\n",STTest[i].CC);
        *test=STTest[i];
       printf("CC:%s\n",STTest[i].CC);
              printf("result:%s\n", test->CC);
           }
    
    }
    return ;
    /*
       return ;*/
     }
    
    void getsub(struct St_test test,char *test1)
    {
        int i;
        int j=10;
         char str1[81];
    
    printf("test:%p,%d,%s,%s,%s\n",&test,test.AA,test.BB,test.CC,tes
    t.subtest[100].AA);
        strcpy(str1,"test1");
        strcpy(test1,str1);
    }
    
     int main(int argc, char *argv[])
     {
        struct St_test test;
       char test1[101];
     init();
       printf("test:%p\n",&test);
       getsub(test,test1);
     getallproc(&test);
       printf("LINE:%d, CC:%s\n",__LINE__,test.CC);
    
       printf("LINE:%d, %d, %s,
    %s\n",__LINE__,test.AA,test.BB,test.CC);
       printf("LINE:%d, %s,CC:%s\n",__LINE__,test.BB,test.CC);
       printf("test:%p\n",&test);
        getsub(test,test1);
    }
    
    
    =====Actual Output:
    $ ./a.out
    test:ffffffffff75390
    Illegal instruction
    $
    
    
    =====Expected Output:
    $ ./a.out
    test:ffffffffff75390
    test:fffffffffeeb110,0,,,
    CC:ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
    ccccccccccccccccccccc
    CC:ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
    ccccccccccccccccccccc
    result:ccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
    ccccccccccccccccccccccccc
    LINE:85,
    CC:ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
    ccccccccccccccccccccc
    LINE:87, 90, aa,
    cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
    cccccccccccccccccc
    LINE:88,
    aa,CC:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
    cccccccccccccccccccccccc
    test:ffffffffff75390
    test:fffffffffeeb110,90,aa,ccccccccccccccccccccccccccccccccccccc
    ccccccccccccccccccccccccccccccccccccccccccccc,aaaaaaaaaaaaaaaaaa
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    aaaaaaaaaaaaa
    $
    

Local fix

  • Compile in 32 bit mode as a workaround.
    

Problem summary

  • USERS AFFECTED:
    Users using 64 bit mode and large stack frames with odd-sized
    variables may be affected by this issue.
    
    PROBLEM DESCRIPTION:
    The application will give an illegal instruction opcode in
    function with large stack frame in 64 bit mode during runtime.
    

Problem conclusion

  • The compiler has been fixed to align stack frame sizes to
    multiples of 4 after mapping auto variables to it, instead of
    later.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI76228

  • Reported component name

    XL C/C++ RHEL52

  • Reported component ID

    5724U8310

  • Reported release

    A10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2011-06-10

  • Closed date

    2011-06-10

  • Last modified date

    2011-06-10

  • APAR is sysrouted FROM one or more of the following:

    IZ92059

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    XL C/C++ RHEL52

  • Fixed component ID

    5724U8310

Applicable component levels

[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"A.1","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
17 October 2021