IBM Support

LI83059: MEMBER OBJECT 'THIS' POINTER INCORRECT WHEN CALLING DESTRUC AFTER EXCEPTION

Subscribe to this APAR

By subscribing, you receive periodic emails alerting you to the status of the APAR, along with a link to the fix after it becomes available. You can track this item individually or track all items by product.

Notify me when this APAR changes.

Notify me when an APAR for this component changes.

 

APAR status

  • Closed as program error.

Error description

  • ERROR DESCRIPTION:
    When using optimization, a base class destructor called during
    exception handling appears to have the wrong 'this' pointer.
    
    The class object is a member is a different class, and is
    preceded in the object by another data member (in the example
    below, 'd_data').  The positioning of the members affects the
    memory offset into the class, and appears to affect the
    incorrect value of the problem class's 'this' pointer.
    
    This issue affects object compiled with both the legacy xlC
    compiler, and the xlclang++ compiler.
    
    
       === TEST CASE ===
    
    #include <cstdio>
    
    class Base {
      int    d_value;
    
      public:
        Base() : d_value(0) { std::printf("ct:  this=%p\n",this); }
        ~Base() { std::printf("dt:  this=%p d_value=%d\n", this,
                  d_value); }
    };
    
    class Derived : public Base {
      public:
        Derived() : Base() { throw 77; }
    };
    
    class DerivedHolder {
      private:
        int d_data;  // Member causing offset of d_derived 'this'
        Derived d_derived;
    
      public:
        explicit DerivedHolder() : d_data(42) , d_derived() { }
    };
    
    int main()
    {
        try {
            DerivedHolder *const holder = ::new DerivedHolder();
            ::delete holder;
        }
        catch (...) { }
        return 0;
    }
    
    
    $ xlC test.cpp
    $ ./a.out
    ct:  this=20002d0c
    dt:  this=20002d0c d_value=0
    $ xlC -O test.cpp
    $ ./a.out
    ct:  this=20002b0c
    dt:  this=20002b08 d_value=42
    
    LOCAL FIX:
    Do not use optimization.
    

Local fix

  • Do not use optimization.
    

Problem summary

  • PROBLEM DESCRIPTION:
    An incorrect memory address is referenced when accessing an
    object member when optimization is used.
    
    USERS AFFECTED:
    Users of optimization, exception handling, and objects
    containing sub-object members.
    

Problem conclusion

  • An issue with code inlining that was affecting how offsets into
    an object were calculated was fixed.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI83059

  • Reported component name

    XL C/C++ LINUX

  • Reported component ID

    5725C7310

  • Reported release

    G11

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2023-09-20

  • Closed date

    2023-09-20

  • Last modified date

    2023-09-20

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

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

Fix information

  • Fixed component name

    XL C/C++ LINUX

  • Fixed component ID

    5725C7310

Applicable component levels

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSXVZZ","label":"XL C\/C++ for Linux"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"G11","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
21 September 2023