IBM Support

LI80912: RUNTIME SEGFAULT WHEN RETURNING DIRECTLY WITHOUT STD::MOVE

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

  • The following test case causes a runtime segfault:
    
    ===== COMPILE COMMAND:
    xlC -g -O0 -std=c++11 test.cc -DFAILPATH
    
    ===== TESTCASE:
    $ cat test.cc
    #include <vector>
    #include <map>
    #include <functional>
    #include <stdio.h>
    
    std::map< int,double>
    MassOfMaterial( const std::vector<double>& RegionVolumes ) {
    
    std::map< int,double> MaterialMass; // Table of masses, Captured
    by reference
    
    // Apply functor to every region
    for( unsigned region=0; region < RegionVolumes.size(); ++region
    ) {
    double currentVolume = RegionVolumes[ region ];
    
    // Computes the mass contribution from a single material within
    a region cell
    // both variants fail with xlc++
    auto massByRegion = [&] ( int ID, double den ) {
    double mass = den * currentVolume;
    auto pair = MaterialMass.insert( std::make_pair(ID,mass) );
    bool worked = pair.second;
    auto iterator = pair.first;
    if( not worked ) { iterator->second += mass; }
    return mass;
    };
    
    massByRegion( 1, 10.0 );
    }
    #ifdef FAILPATH
    // fails with SEG FAULT using XLC without the std::move
    return MaterialMass;
    #else
    return std::move(MaterialMass);
    #endif
    }
    
    int main(int argc, char** argv) {
    
    std::vector<double> volumes = { .9, 9.0, 90.0 };
    
    std::map< int,double> mass_of_each_material = MassOfMaterial(
    volumes );
    
    // 3 cells each with density 10.0, .9*10 + 9*10 + 90*10 =
    99.9*10 = 999
    double expected_value = 999.0;
    double value = mass_of_each_material[1];
    
    if( value < (expected_value-1.0e-14 ) or value >
    (expected_value+1.0e-14
    ) ) {
    printf("FAILURE: value was %f but should be %f !! \n", value,
    expected_value );
    } else {
    printf("PASS: value is correct, %f .\n", value );
    }
    return 0;
    }
    // END OF testcase.cc
    $
    
    
    ===== WORKAROUND:
    Use std::move
    
    ===== ACTUAL OUTPUT:
    $ ./a.out
    Memory fault
    $
    
    ===== EXPECTED OUTPUT:
    $ ./a.out
    PASS: value is correct, 999.000000 .
    $
    

Local fix

  • N/A
    

Problem summary

  • USERS AFFECTED:
    Users who do not use the std::move may be affected by this
    issue.
    
    PROBLEM DESCRIPTION:
    For the reproted test case, clients who do not use the
    std::move run into a segfault at runtime.
    An internal runtime optimization was incorrectly checking for
    an assignment leading to the segfault.
    

Problem conclusion

  • The runtime check has been corrected.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI80912

  • Reported component name

    XL C/C++ FOR LI

  • Reported component ID

    5725C7300

  • Reported release

    G11

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2019-06-19

  • Closed date

    2019-06-21

  • Last modified date

    2019-06-21

  • 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



Document information

More support for: XL C/C++ for Linux

Software version: G11

Reference #: LI80912

Modified date: 21 June 2019