IBM Support

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

    LI76226

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

    LI76071

  • 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

  • RA10 PSY

       UP

[{"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