IBM Support

PI68951: VARIABLE ASSIGNMENT AFTER __SET_FAR_ALET_OFFSET() OPTIMIZED AWAY

A fix is available

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When code optimization is enabled, a variable assignment
    statement is optimized away when two separate
    __set_far_ALET_offset() calls are made to potentially two
    different data spaces.  The compiler appears to assume that the
    two returned pointers are pointing to the same memory location,
    so the code optimizer decides to remove variable assignment
    statements via the first pointer.
    
    
       === TEST CASE ===
    
    #include <metal.h>
    #include <builtins.h>
    
    typedef struct
    {
      int val;
    } MyStruct;
    
    void testfunc(MyStruct * __far a);
    
    void test(void * off, int alet1, int alet2)
    {
      MyStruct * __far s1 = (MyStruct * __far)
       __set_far_ALET_offset(alet1, off);
      s1->val = 10;   // Optimized away
    
     //__fence();    // Workaround
    
      MyStruct * __far s2 = (MyStruct * __far)
       __set_far_ALET_offset(alet2, off);
      s2->val = 20;
    
      testfunc(s1);
      testfunc(s2);
    }
    
    int main(void)
    {
      MyStruct a = { 0 };
      test(&a, 0, 1);
      return 0;
    }
    
    
    $ xlc apar.c -S -Wc,"METAL,NOSEQ,SS,NOSEARCH
    SEARCH(/util/usr/include/metal/),OPT(2),ARMODE"
    $
    $ cat apar.s
    ...
    L     15,=V(TESTFUNC)                        000023
             SAR   14,14                         000013
    *    __set_far_ALET_offset(alet1, off);      000014
    *   s1->val = 10;   // Optimized away        000015
    *                                            000016
    *  //__fence();    // Workaround             000017
    *                                            000018
    *   MyStruct * __far s2 = (MyStruct * __far) 000019
             L     14,@79alet2                   000019
             STAM  14,14,244(13) _a2_d244_l4_    000023
    ...
    

Local fix

  • - Do not use code optimization (i.e. OPT(0) )
    - Include a __fence() call between the __set_far_ALET_offset()
    calls to prevent optimization code motion between the two
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED: Metal C users using AR mode.                 *
    ****************************************************************
    * PROBLEM DESCRIPTION: There is a possibility that an          *
    *                      indirect store via pointer will be      *
    *                      removed because it is thought to be     *
    *                      dead. The situation requires that the   *
    *                      pointer bethe same except the ALET      *
    *                      used to accessthe memory is different   *
    *                      In such acaseone store may be           *
    *                      interpreted asoverwriting a previous    *
    *                      one where actually they are writing     *
    *                      to different address spaces.            *
    ****************************************************************
    * RECOMMENDATION: Apply the provided PTF.                      *
    *                                                              *
    ****************************************************************
    .
    

Problem conclusion

  • Apply provided fix.
    

Temporary fix

Comments

APAR Information

  • APAR number

    PI68951

  • Reported component name

    C/C++ FOR MVS

  • Reported component ID

    56551210A

  • Reported release

    7A0

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2016-09-12

  • Closed date

    2016-09-28

  • Last modified date

    2016-12-01

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

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

Modules/Macros

  • CCNETBY
    

Fix information

  • Fixed component name

    C/C++ FOR MVS

  • Fixed component ID

    56551210A

Applicable component levels

  • R7A0 PSY UI41215

       UP16/11/02 P F611

Fix is available

  • Select the PTF appropriate for your component level. You will be required to sign in. Distribution on physical media is not available in all countries.

[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SG19M","label":"APARs - z\/OS environment"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"7A0","Edition":"","Line of Business":{"code":"","label":""}},{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSQKCWV","label":"IBM C\/C++ for MVS\/ESA"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"7A0","Edition":"","Line of Business":{"code":"LOB35","label":"Mainframe SW"}}]

Document Information

Modified date:
09 August 2024