Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-539

[Sun C++ 5.9] std::uncaught_exception() false in terminate handler, SIGSEGV in std::unexpected

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • External
    • None
    • Sun C++ 5.9 (Sun Studio 12)

    Description

      -------- Original Message --------
      Subject: Re: (Incident Review ID: 1044672) std::uncaught_exception() false in terminate handler, SIGSEGV in std::unexpected
      Date: Tue, 28 Aug 2007 11:10:28 -0700 (MST)
      From: Steve Clamage <Stephen.Clamage@Sun.COM>
      To: sebor@roguewave.com

      Hi Martin Sebor,

      Thank you for reporting this issue.

      We have determined that this report is a new bug and entered the bug into our internal bug tracking system under Bug Id: 6598218.

      You can monitor this bug on the Java Bug Database at
      http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6598218.

      It may take a day or two before your bug shows up in this external database. If you are a member of the Sun Developer Network (SDN), there are two additional options once the bug is visible.

      1. Voting for the bug
      Click http://bugs.sun.com/bugdatabase/addVote.do?bug_id=6598218.

      2. Adding the report to your Bug Watch list.
      You will receive an email notification when this bug is updated.
      Click http://bugs.sun.com/bugdatabase/addBugWatch.do?bug_id=6598218.

      The Sun Developer Network (http://developers.sun.com) is a free service that Sun offers. To join, visit https://softwarereg.sun.com/registration/developer/en_US/new_user.

      For a limited time, SDN members can obtain fully licensed Java IDEs for web and enterprise development. More information is at http://developers.sun.com/prodtech/javatools/free/.

      Regards,
      Steve

      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      NOTICE: This message, including any attachments, is for the intended
      recipient(s) only. If you are not the intended recipient(s), please
      reply to the sender, delete this message, and refrain from disclosing,
      copying, or distributing this message.
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      --------------- Previous Messages ----------------

      --------------------- Report ---------------------

      category : c++
      subcategory : library
      release : studio11
      type : bug
      synopsis : std::uncaught_exception() false in terminate handler, SIGSEGV in std::unexpected
      customer name : Martin Sebor
      customer mail : sebor@roguewave.com
      sdn id :
      language : en
      company : Rogue Wave Software
      hardware : sun4
      os : solaris_10
      bug id : 6598218
      date created : Mon Aug 27 19:08:24 MST 2007
      date evaluated : Tue Aug 28 11:07:08 MST 2007
      description :
      FULL PRODUCT VERSION :

      ADDITIONAL OS VERSION INFORMATION :
      Solaris 10

      A DESCRIPTION OF THE PROBLEM :
      According to 18.6.4, p1, std::uncaught_exception() is required to return true when terminate() is entered for any reason other than an explicit call to terminate(), and to continue to return true while executing the installed terminate handler. The program below shows that the Sun C++ implementation fails to follow this requirement.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the test case below (named t.cpp) using CC t.cpp and run the executable.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      testing uncaught_exception() after a call to unexpected()
      unexpected handler: uncaught_exception () == 0, got 0
      PASS
      uncaught_exception() after an implicit call to terminate()
      terminate handler: uncaught_exception () == 1, got 1
      PASS
      uncaught_exception() after an explicit call to terminate()
      terminate handler: uncaught_exception () == 0, got 0
      PASS
      uncaught_exception() after an explicit call to unexpected() during a throw
      terminate handler: uncaught_exception () == 0, got 0
      PASS

      ACTUAL -
      CC: Sun C++ 5.9 SunOS_sparc 2007/05/03
      /amd/packages/mdx/solaris/SUNWspro/C+5.9/prod/bin/cfilt: Sun C+ 5.9 SunOS_sparc 2007/05/03
      ccfe: Sun C++ 5.9 SunOS_sparc 2007/05/03
      ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.482
      testing uncaught_exception() after a call to unexpected()
      unexpected handler: uncaught_exception () == 0, got 0
      PASS
      uncaught_exception() after an implicit call to terminate()
      terminate handler: uncaught_exception () == 1, got 0
      FAIL
      uncaught_exception() after an explicit call to terminate()
      terminate handler: uncaught_exception () == 0, got 0
      PASS
      uncaught_exception() after an explicit call to unexpected() during a throw
      Segmentation Fault - core dumped
      FAIL

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      #include <exception>
      #include <stdio.h>
      #include <stdlib.h>

      bool expect_uncaught;
      const char* which;

      void handler ()
      {
      const bool uncaught = std::uncaught_exception ();

      printf ("%s handler: uncaught_exception () == %d, got %d\n",
      which, expect_uncaught, uncaught);

      exit (expect_uncaught == uncaught ? 0 : 1);
      }

      void invoke_unexpected () throw ()

      { throw 0; }

      void test_unexpected ()
      {
      puts ("testing uncaught_exception() after a call to unexpected()");

      std::set_unexpected (handler);

      expect_uncaught = false;
      which = "unexpected";
      invoke_unexpected ();
      }

      int evaluate (int select)
      {
      if (2 == select)

      { expect_uncaught = true; throw 0; }

      else if (3 == select)
      std::terminate ();
      else
      std::unexpected ();

      return 0;
      }

      void test_terminate (int select)
      {
      printf ("uncaught_exception() after an %s call to %s\n",
      2 == select ? "implicit" : "explicit",
      select < 4 ? "terminate()" : "unexpected() during a throw");

      std::set_terminate (handler);
      which = "terminate";

      throw evaluate (select);
      }

      int main (int argc, char *argv[])
      {
      if (1 == argc)

      { printf ("%s\n", system ("./a.out 1") ? "FAIL" : "PASS"); printf ("%s\n", system ("./a.out 2") ? "FAIL" : "PASS"); printf ("%s\n", system ("./a.out 3") ? "FAIL" : "PASS"); printf ("%s\n", system ("./a.out 4") ? "FAIL" : "PASS"); }

      else

      { int select = argv [1][0] - '0'; 1 < select ? test_terminate (select) : test_unexpected (); }

      }

      ---------- END SOURCE ----------

      Attachments

        Activity

          People

            Unassigned Unassigned
            sebor Martin Sebor
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: