IBM Support

LI76248: SEGMENTATION FAULT AT O3 WITHIN NESTED LOOP

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • A segmentation fault is encountered at -O3 optimization whe
    runnning a test case that contains a nested loop.
    
    ==== Test case:
    test.c:
    #include <stdlib.h>
    #include <stdio.h>
    
    typedef struct {
      void *params;
    } Temp;
    
    void * get_params(Lattice *lat)
    {
      return lat->params;
    }
    
    void get_loop(Temp *lat, int x[], int nd, int index)
    {
      void *p = get_params(lat);
    
      for(int i=0; i<nd; i++) {
        x[i] = index;
      }
    }
    
    void CreateNestedBlock(int nd, Lattice *lat)
    {
      for(int b=0; b<2; b++) {
       int xf[nd];
        for(int j=0; j<1; j++) {
          get_loop(lat, xf, nd, j);
        }
      }
    }
    
    int main(int argc, char *argv[])
    {
      int ndim = 4;
      Temp lat;
      lat.params = NULL;
    
      printf("starting\n");
      CreateNestedBlock(ndim, &lat);
      printf("done\n");
    
      return 0;
    }
    
    
    ==== Observed Output:
    $ xlc -O3 test.c
    staring
    Segmentation fault
    $
    

Local fix

  • Use a lower optimization level.
    

Problem summary

  • PROBLEM DESCRIPTION:
    Segmentation fault at -O3 when returning from a function.
    
    USERS AFFECTED:
    Users of optimization levels -O3 or higher.
    

Problem conclusion

  • Intermediate generated code was incorrectly moved outside of an
    internal optimized loop. Resulting in the corruption of the
    return address of the function. This fix involves ensuring that
    this particular block of code is not moved outside of the loop.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI76248

  • Reported component name

    XL C/C++ SLES10

  • Reported component ID

    5724U8300

  • 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:

    LI76071

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

Fix information

  • Fixed component name

    XL C/C++ SLES10

  • Fixed component ID

    5724U8300

Applicable component levels

  • RA10 PSY

       UP



Document information

More support for: XL C/C++

Software version: A.1

Reference #: LI76248

Modified date: 10 June 2011