IBM Support

IV97966: MEMORY FAULT WITH -QIPA=PARTITION=LARGE

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • The following test case produces a memory fault when compiled
    with -qipa=partition=large
    
    It references the memory address for "PREV" and finds a bad
    pointer, e.g. a NULL pointer
    
    What the test-case does is to create a linked-list and to insert
    one element.
    
    
    ====COMPILE COMMAND:
    xlc -qipa=partition=large test.c
    
    
    ====TESTCASE:
    #include <stdio.h>
    
    /*  Node and header for a doubly linked list  */
    typedef struct node_t node_t;
    struct node_t
    {
        /*  Do not change the sequence of these members!  */
        node_t *Next;
        node_t *Prev;
    
        /*  Anticipate padding and make content big enough  */
        char content[sizeof(node_t *)];
    };
    
    typedef struct
    {
        node_t *First;
        node_t *Dummy; /*  is always NULL  */
        node_t *Last;
    
        void *OtherStuff1;
        void *OtherStuff2;
    }
    list_t;
    
    int main(void)
    {
        list_t mylist;
        node_t mynode0, *mynode, *lastnode;
    
        printf("================= Compile time %s\n", __TIME__);
    
        /* ******  Initialize list   ********** */
        mylist.First = (node_t *)&(mylist.Dummy);
        mylist.Dummy = NULL;
        mylist.Last = (node_t *)&(mylist.First);
    
        printf("my list is (%p): entries FIRST (%p) = %p, DUMMY (%p)
    = %p, LAST (%p) = >>>>> %p <<<<<<\n",
               &mylist,
               &(mylist.First), mylist.First, &(mylist.Dummy),
    mylist.Dummy, &(mylist.Last), mylist.Last);
    
        mynode = &mynode0;
    
        /* *****  Add "mynode" at the end of the list  ***** */
        lastnode = (node_t *)&(mylist.Dummy);
    
        printf("----------------- watch out for faulty 'PREV'!
    ----------------\n");
        printf("Last node is (%p): NEXT (%p) = %p, PREV (%p) >>>>>
    %p <<<<\n",
               lastnode, &(lastnode->Next), lastnode->Next,
    &(lastnode->Prev), lastnode->Prev);
    
        mynode->Next         = lastnode;
        mynode->Prev         = lastnode->Prev;
        lastnode->Prev->Next = mynode;  /*  << this crashes!  */
        lastnode->Prev       = mynode;
    
        return 0;
    }
    
    $
    
    
    ===== ACTUAL OUTPUT:
    $ ./a.out
    ================= Compile time 09:19:27
    my list is (2ff22560): entries FIRST (2ff22560) = 2ff22564,
    DUMMY (2ff22564) = 0, LAST (2ff22568) = >>>>> 2ff22560 <<<<<<
    ----------------- watch out for faulty 'PREV'! ----------------
    Last node is (2ff22564): NEXT (2ff22564) = 0, PREV (2ff22568)
    >>>>> 0 <<<<
    Memory fault
    $
    
    
    ===== EXPECTED OUTPUT:
    $ ./a.out
    ================= Compile time 09:23:06
    my list is (2ff22570): entries FIRST (2ff22570) = 2ff22574,
    DUMMY (2ff22574) = 0, LAST (2ff22578) = >>>>> 2ff22570 <<<<<<
    ----------------- watch out for faulty 'PREV'! ----------------
    Last node is (2ff22574): NEXT (2ff22574) = 0, PREV (2ff22578)
    >>>>> 2ff22570 <<<<
    $
    

Local fix

  • N/A
    

Problem summary

  • USERS AFFECTED:
    Users who compile with compiled with -qipa=partition=large may
    be affected by this issue.
    
    PROBLEM DESCRIPTION:
    For an internal optimization, the compiler was considering a
    zero offset when trying to access an internal object.
    

Problem conclusion

  • The compiler has been changed to consider a non-zero offset when
    trying to access an internal object.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IV97966

  • Reported component name

    XL C/C++ FOR AI

  • Reported component ID

    5725C7200

  • Reported release

    C10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2017-07-13

  • Closed date

    2018-06-21

  • Last modified date

    2018-06-21

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

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

    IJ07800

Fix information

  • Fixed component name

    XL C FOR AIX

  • Fixed component ID

    5725C7100

Applicable component levels

  • RC10 PSY

       UP



Document information

More support for: XL C for AIX
Compiler

Software version: 12.1

Reference #: IV97966

Modified date: 21 June 2018