AIX Open Source

 View Only
Expand all | Collapse all

core file with new version of g++

  • 1.  core file with new version of g++

    Posted Thu October 20, 2022 06:51 PM

    We moved from gcc 4.8.4 to  8.3.0.  When we run some regression testing we get a core file when we try to throw an exception.  The code throwing the exception is this:

    char s[2048];
    snprintf(s, 2048, "Assertion has failed ...");
    throw std::runtime_error(s);



    This is caught in main with this:

    catch (std::exception &ex) {
        fprintf(stderr, "An exception occurred, processing has terminated abnormally. Specific messages follow:\n%s\n", ex.what());
        exit(EXIT_FAILURE);
    }


    The stack shows this:
    $ cat core_stack.txt
    raise.raise(??) at 0xd01247c8
    abort.abort() at 0xd018a6b8
    vterminate.__gnu_cxx::__verbose_terminate_handler()(), line 95 in "vterminate.cc"
    eh_terminate.__cxxabiv1::__terminate(void (*)())(handler = ??), line 47 in "eh_terminate.cc"
    eh_terminate.std::terminate()(), line 57 in "eh_terminate.cc"
    eh_throw.__cxa_throw(obj = @0x200469f8, tinfo = ??, dest = ??), line 95 in "eh_throw.cc"
    FilterAssertNoMediumOverlays.(anonymous namespace)::FilterAssertNoMediumOverlays::doThrow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)(0x20035628, 0x20035680), line 96 in "FilterAssertNoMediumOverlays.cpp"

    I tried to pull out the problem code into a file:

    #include <string>
    #include <stdexcept>
    
    int main(int argc,char *argv[])
    {
       //Catch unexpected exceptions.
       try {
            char s[2048];
            snprintf(s, 2048, "This is a test");
            throw std::runtime_error(s);
       }
       catch (std::exception &ex) {
          fprintf(stderr, "An exception occurred, processing has terminated abnormally. Specific messages follow:\n%s\n", ex.what());
          exit(EXIT_FAILURE);
       }
    }
    

    and that runs without error.  Could it be because we link in some older code even if it is not used?

    Thanks




    ------------------------------
    Adam Swartz
    ------------------------------


  • 2.  RE: core file with new version of g++

    Posted Fri October 21, 2022 02:44 AM
    Are both of these files compiled with same compiler and there is no other older library and other compiled unit ?

    ------------------------------
    SANKET RATHI
    ------------------------------



  • 3.  RE: core file with new version of g++

    Posted Fri October 21, 2022 10:48 AM
    Edited by Adam Swartz Fri October 21, 2022 10:49 AM
    Sanket, I will try to confirm today.  I believe the test removed the older libs and everything was freshly compiled, but I will double check.

    Thanks

    ------------------------------
    Adam Swartz
    ------------------------------



  • 4.  RE: core file with new version of g++

    Posted Fri October 21, 2022 12:47 PM
    Sanket,
      I confirmed all object files are fresh and nothing else is linking in.

    Here is the command line message.  
    $ afpsak -f assertNoMediumOverlays in.afp
    terminate called after throwing an instance of 'std::runtime_error'
    what(): Assertion has failed in filter "assertNoMediumOverlays". The medium map with name "AAAPRIME" defines a medium overlay and is invoked just before page sequence 1.
    IOT/Abort trap(coredump)​

    Compile options:
    g++ -maix64 -g -O0 -o obj/${i}.o -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -Isrc -I. -funsigned-char -c file.cpp​

    Link options:

    g++ -maix64 -g -O0 -o bin/afpsak \
        -Wl,-bnoipath \
        all the object files

    The link only includes the object files I compiled.  Compiler info:

    $ g++ -v
    Using built-in specs.
    COLLECT_GCC=g++
    COLLECT_LTO_WRAPPER=/opt/freeware/libexec/gcc/powerpc-ibm-aix7.2.0.0/8/lto-wrapper
    Target: powerpc-ibm-aix7.2.0.0
    Configured with: ../gcc-8.3.0/configure --prefix=/opt/freeware --mandir=/opt/freeware/man --infodir=/opt/freeware/info --with-local-prefix=/opt/freeware --with-as=/usr/bin/as --with-ld=/usr/bin/ld --enable-languages=c,c++,fortran,go --enable-version-specific-runtime-libs --disable-nls --enable-decimal-float=dpd --disable-libstdcxx-pch --enable-__cxa_atexit --disable-werror --enable-libstdcxx-filesystem-ts --with-gcc-major-version-only --program-suffix=-8 --disable-rpath --host=powerpc-ibm-aix7.2.0.0
    Thread model: aix
    gcc version 8.3.0 (GCC)
    

    OS:

    $ oslevel -s
    7200-05-03-2148
    



    Thanks!!




    ------------------------------
    Adam Swartz
    ------------------------------



  • 5.  RE: core file with new version of g++

    Posted Fri October 21, 2022 12:48 PM
    Adding a header dump:
    $ dump -H -X64 bin/afpsak
    
    bin/afpsak:
    
                            ***Loader Section***
                          Loader Header Information
    VERSION#         #SYMtableENT     #RELOCent        LENidSTR
    0x00000001       0x00000123       0x00002c44       0x000000fd
    
    #IMPfilID        OFFidSTR         LENstrTBL        OFFstrTBL
    0x00000004       0x0002dfc0       0x00002760       0x0002e0bd
    
    
                            ***Import File Strings***
    INDEX  PATH                          BASE                MEMBER
    0      /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/ppc64:/opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8:/opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/../../..:/opt/freeware/lib:/usr/lib:/lib
    1                                    libc.a              shr_64.o
    2                                    libstdc++.a         libstdc++.so.6
    3                                    libgcc_s.a          shr.o
    ​


    ------------------------------
    Adam Swartz
    ------------------------------



  • 6.  RE: core file with new version of g++

    Posted Fri October 21, 2022 02:33 PM
    I used the wrong debugger, this is the gdb stack trace:

    (gdb) where
    #0  0x09000000000416ac in raise () from /usr/lib/libc.a(shr_64.o)
    #1  0x090000000005f73c in abort () from /usr/lib/libc.a(shr_64.o)
    #2  0x0900000012328f10 in __gnu_cxx::__verbose_terminate_handler ()
        at ../../../../gcc-8.3.0/libstdc++-v3/libsupc++/vterminate.cc:42
    #3  0x09fffffff000ec40 in _$STATIC () from /usr/ccs/bin/usla64
    #4  0x0900000012328d4c in __gnu_cxx::__verbose_terminate_handler ()
        at ../../../../gcc-8.3.0/libstdc++-v3/libsupc++/vterminate.cc:7
    #5  0x28244822ffff6098 in ?? ()
    #6  0x00000001002ac648 in (anonymous namespace)::FilterAssertNoMediumOverlays::doThrow (
        this=0x900000012485720 <_GLOBAL__F_.._.._.._.._.._gcc_8.3.0_libstdc___v3_src_c__11_string_inst.cc_FB5499C7_0xf074c1e4+4704>, mmName=...) at src/AfpFiltersExternal/FilterAssertNoMediumOverlays.cpp:96
    ​
    Sort of looks like it is using the wrong libs?

    ------------------------------
    Adam Swartz
    ------------------------------



  • 7.  RE: core file with new version of g++

    Posted Fri October 21, 2022 06:02 PM
    I stepped through the debugger with the test file and problem file.  I found the test file's last line was 371 in char_traits.h:
    (gdb) info line
    Line 371 of "/opt/freeware/src/packages/BUILD/gcc-build-8.3.0/powerpc-ibm-aix7.2.0.0/libstdc++-v3/include/bits/char_traits.h" starts at address 0x12338978 <_ZNSi6ignoreEl+512> and ends at 0x12338988 <_ZNSi6ignoreEl+528>.
    (gdb) bt
    #0  0x0900000012338980 in std::istream::ignore (this=0x90, __n=<incomplete type>)
        at /opt/freeware/src/packages/BUILD/gcc-build-8.3.0/powerpc-ibm-aix7.2.0.0/libstdc++-v3/include/bits/char_traits.h:371
    #1  0x000000010000074c in main (argc=0, argv=0x110001208 <_cce3nhgc.rw_+360>) at test.cpp:10
    (gdb) si
    An exception occurred, processing has terminated abnormally. Specific messages follow:
    This is a test
    [Inferior 1 (process 33882590) exited with code 01]​
    while the coring program's last lines are
    (gdb) info line
    Line 1334 of "/opt/freeware/src/packages/BUILD/gcc-build-8.3.0/powerpc-ibm-aix7.2.0.0/libstdc++-v3/include/bits/char_traits.h" starts at address 0x12338978 <_ZNSi6ignoreEl+512> and ends at 0x12338988 <_ZNSi6ignoreEl+528>.
    (gdb) bt
    #0  0x0900000012338980 in std::istream::ignore (this=0x90, __n=<incomplete type>)
        at /opt/freeware/src/packages/BUILD/gcc-build-8.3.0/powerpc-ibm-aix7.2.0.0/libstdc++-v3/include/bits/char_traits.h:1334
    #1  0x0000000100283834 in (anonymous namespace)::FilterAssertNoMediumOverlays::doThrow (this=0x0, mmName=...)
        at src/AfpFiltersExternal/FilterAssertNoMediumOverlays.cpp:96
    #2  0x0000000100283668 in (anonymous namespace)::FilterAssertNoMediumOverlays::write (this=0x0,
        buf=0x110013298 <_cczixF3b.rw_+43832>, bufSize=1) at src/AfpFiltersExternal/FilterAssertNoMediumOverlays.cpp:84
    #3  0x000000010005bbc0 in AfpOutputFilter::sink_write (this=<incomplete type>, buf=<incomplete type>, bufSize=173)
        at src/AfpFiltersInternal/AddSuppressTextToFormdef.cpp:67
    #4  0x00000001000ead90 in (anonymous namespace)::FilterInputFile::close (this=0x110045470)
        at src/AfpFiltersExternal/FilterInputFile.cpp:93
    #5  0x0000000100001380 in main (argc=1, argv=0x0) at src/afpsak.cpp:138
    
    (gdb) si
    terminate called after throwing an instance of 'std::runtime_error'
      what():  Assertion has failed in filter "assertNoMediumOverlays". The medium map with name "AAAPRIME" defines a medium overlay and is invoked just before page sequence 1.
    
    Program received signal SIGABRT, Aborted.
    0x09000000000416ac in raise () from /usr/lib/libc.a(shr_64.o)
    
    ​

    That line number looks out of range since the header is only 708 lines long.



    ------------------------------
    Adam Swartz
    ------------------------------



  • 8.  RE: core file with new version of g++

    Posted Tue October 25, 2022 02:32 PM
    Hi Adam,

    Is there a simple testcase that you can share to reproduce the problem ? We would like to try on our test system.

    ------------------------------
    SANKET RATHI
    ------------------------------



  • 9.  RE: core file with new version of g++

    Posted Thu May 04, 2023 03:48 PM

    Sanket,
      It has been a long time since the last post, but I was able to confirm this is a bug in the compiler on AIX.  Our old compiler (4.2.4) does not cause a core.  The same code when compiled on Linux or other platforms does not create a core either.  I was able to pare down the code to some sample code that can reproduce the problem.  The heart of the problem is that a try/catch block is not being honored.  It is like it forgets it is in the try/catch and therefore cores.  Where would I send source to so they can work on a fix?  I would prefer not to post it on the forum.

    $oslevel -s
    7200-05-03-2148
    $gcc --version
    gcc (GCC) 10.3.0

    Thanks,
    Adam



    ------------------------------
    Adam Swartz
    ------------------------------



  • 10.  RE: core file with new version of g++

    Posted Mon May 08, 2023 01:29 PM

    If you do not want to send on forum then you can send me privately.

     

     

    Thanks,

     

    Sanket Rathi

     






  • 11.  RE: core file with new version of g++

    Posted Mon May 08, 2023 07:58 PM

    Thanks Sanket.  I sent a connection request, is that how I get your information?



    ------------------------------
    Adam Swartz
    ------------------------------



  • 12.  RE: core file with new version of g++

    Posted Tue May 09, 2023 01:36 AM

    There is a reply privately option. 



    ------------------------------
    SANKET RATHI
    ------------------------------



  • 13.  RE: core file with new version of g++

    Posted Mon May 15, 2023 11:08 AM

    Can you please verify the code was received?  Will there be a JIRA issue I can watch or something in order to get status on this?

    Thanks,

    Adam



    ------------------------------
    Adam Swartz
    ------------------------------



  • 14.  RE: core file with new version of g++

    Posted Tue May 09, 2023 10:17 AM
      |   view attached

    Here is the code.  I sent the password privately. There is no makefile, but the shell script will build it.  Just run the resulting bin/TestCreateByMethodV4 program and you will get the core.  TestCreateByMethod.cpp is the entry point and wraps everything in a try catch.  I had to have several levels of inheritance with the template to recreate the core.

    Thanks!



    ------------------------------
    Adam Swartz
    ------------------------------

    Attachment(s)

    zip
    SimpleClassV4.zip   5 KB 1 version


  • 15.  RE: core file with new version of g++

    Posted Fri May 19, 2023 10:30 AM

    Sanket, I haven't heard anything more since I posted the sample code.  Any updates?  Is there a JIRA I can watch or something?



    ------------------------------
    Adam Swartz
    ------------------------------



  • 16.  RE: core file with new version of g++

    Posted Fri May 19, 2023 01:09 PM

    Hi Adam,

     

    I sent you a private message not sure if you receive.

    But I could not find the sample code.

     

    Thanks,

     

    Sanket Rathi

     






  • 17.  RE: core file with new version of g++

    Posted Thu May 25, 2023 10:45 AM

    I am trying to reply directly, but my sent messages never show the message as being sent, so trying here as well.

    Sangamesh,
    I don't know why my replies are not working, but trying again.  There is a script included to compile on your machine (compile_test.sh).

    Thanks,
    Adam



    ------------------------------
    Adam Swartz
    ------------------------------



  • 18.  RE: core file with new version of g++

    Posted Fri June 16, 2023 12:12 PM
    Edited by Adam Swartz Fri June 16, 2023 12:13 PM

    I just wanted to post an update in case anyone else runs into this.  This issue is related this gcc bug:

    60939 – AIX: exceptions not caught when calling function via pointer (gnu.org)

    It looks like it started in gcc 4.8.0 and that you will probably need to use the workaround listed in the link.



    ------------------------------
    Adam Swartz
    ------------------------------