IBM Support

IZ87561: ASSERT FAILURE WHEN COMPILED WITH -G

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The following test program shows problems while
    compiling with V10.1 and option -g. The program encounters an
    assert.
    
    ===== COMPILE COMMAND:
    cc -g -qlanglvl=extc99 -l pthread myiov.c
    
    ===== TESTCASE:
    $ cat myiov.c
    #include <assert.h>
    #include <pthread.h>
    #include <sys/uio.h>
    #include <stdio.h>
    
    
    
    static void
    doit( const unsigned runs )
    {
        const unsigned e1 = 0xdeadbeef;
    
    
        const unsigned dimension = ((runs+1)%10)*2;
        struct iovec myiov[dimension];
    
        for (unsigned i=0; i< (dimension); i++ ) {
            myiov[i].iov_base = &i;
            myiov[i].iov_len  = i;
            assert( e1 == 0xdeadbeef );
            usleep(runs%10);
            for (unsigned k=0;k< dimension; k++) {
                assert( (void*)&e1 != (void*)&myiov[k] );
            }
        }
    }
    
    static void* body(void* v)
    {
        unsigned runs = 0;
        while ( v ) {
            doit( ++runs );
    
            if ( runs %1000 == 0 )
                 printf("runs %04u %u\n", pthread_self(), runs );
    
        }
        return v;
    }
    
    int
    main( int argc __attribute__((unused)), char *argv[]
    __attribute__((unused)) )
    {
    
        unsigned runs = 2467638383;
    
        for (unsigned i=0; i<10; i++) {
            pthread_t thread_id;
            const int rc = pthread_create( &thread_id, NULL, body,
    &runs  );
            assert( rc == 0 );
        }
        body(&runs);
        return 0;
    }
    
    $
    
    
    ===== ACTUAL OUTPUT:
    $ ./a.out
    runs 0258 1000
    runs 0515 1000
    runs 1543 1000
    runs 0001 1000
    .
    .
    .
    runs 1029 9000
    runs 2057 9000
    Assertion failed: (void*)&e1 != (void*)&myiov[k], file  myiov.c,
    line 23
    IOT/Abort trap
    $
    
    ===== EXPECTED OUTPUT:
    $ ./a.out
    runs 0515 1000
    runs 1543 1000
    runs 2571 1000
    runs 1800 1000
    runs 2057 1000
    runs 1286 1000
    runs 2314 1000
    .
    .
    .
    //should not trap
    

Local fix

  • n/a
    

Problem summary

  • USERS AFFECTED:
    User of variable length arrays together with -g may be affected
    by this issue.
    
    PROBLEM DESCRIPTION:
    There occurs a race condition with variable length arrray code
    in debug mode that causes the application to core.
    

Problem conclusion

  • The compiler has been fixed to change the way temporaries for
    variable length arrays are generated to avoid the race
    condition when -g is used.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IZ87561

  • Reported component name

    XL C++ AIX

  • Reported component ID

    5724U8100

  • Reported release

    A10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2010-10-28

  • Closed date

    2011-01-21

  • Last modified date

    2011-01-24

Fix information

  • Fixed component name

    XL C AIX

  • Fixed component ID

    5724U8000

Applicable component levels

[{"Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"A.1"}]

Document Information

Modified date:
06 October 2021