[Bug 1439451] Re: std::uncaught_exception() returns true after catching an exception thrown with std::rethrow_exception

Bug Watch Updater 1439451 at bugs.launchpad.net
Thu Apr 2 02:22:24 UTC 2015


Launchpad has imported 10 comments from the remote bug at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62258.

If you reply to an imported comment from within Launchpad, your comment
will be sent to the remote bug automatically. Read more about
Launchpad's inter-bugtracker facilities at
https://help.launchpad.net/InterBugTracking.

------------------------------------------------------------------------
On 2014-08-25T18:06:12+00:00 Dmitry Prokoptsev wrote:

After using std::rethrow_exception() (and catching the exception), all
subsequent calls to std::uncaught_exception() return `true', which is
obviously not the way it was meant to work.

A simple test case is attached.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.9/+bug/1439451/comments/0

------------------------------------------------------------------------
On 2014-08-25T18:06:50+00:00 Dmitry Prokoptsev wrote:

Created attachment 33394
A simple test case.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.9/+bug/1439451/comments/1

------------------------------------------------------------------------
On 2014-08-25T18:11:32+00:00 Dmitry Prokoptsev wrote:

Created attachment 33395
Proposed patch

I believe the problem is that std::rethrow_exception() does not update
`__cxa_eh_globals::uncaughtExceptions' (which remains zero), while
__cxa_begin_catch() decrements it to -1.

A proposed patch is attached.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.9/+bug/1439451/comments/2

------------------------------------------------------------------------
On 2014-08-29T10:27:28+00:00 Deniz Bahadir wrote:

I can confirm this bug.
It even occurs with GCC 4.8.2 (on Ubuntu 14.04).

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.9/+bug/1439451/comments/3

------------------------------------------------------------------------
On 2014-10-07T08:57:06+00:00 Ai-azuma wrote:

PR61643 shares the root cause with this PR. The behavior of the test
case in PR61643 completely agrees with the analysis in Comment 2, and
the proposed patch makes the test case in PR61643 work properly.

I confirmed that this bug was reproduced with 4.8.4 20140925, 4.9.2
20140924 and 5.0.0 20140928.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.9/+bug/1439451/comments/4

------------------------------------------------------------------------
On 2014-10-07T09:02:11+00:00 Ai-azuma wrote:

*** Bug 61643 has been marked as a duplicate of this bug. ***

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.9/+bug/1439451/comments/5

------------------------------------------------------------------------
On 2015-01-20T10:12:24+00:00 P-bartosiewi wrote:

I can also confirm this bug (I have a test case with std::async and
future, but it internally uses std::rethrow_exception).

Known to work: gcc 4.6.3, 4.7.2, 4.8.1
Known to fail: gcc 4.8.2, 4.9.2, clang 3.5.0
So this is a regression.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.9/+bug/1439451/comments/6

------------------------------------------------------------------------
On 2015-01-26T16:29:44+00:00 Public-n wrote:

Confirmed using GCC 5.0.0 20150125 built from source (see below) and
4.7.2 (Debian 4.7.2-5; Debian Wheezy). Tested using the test case in
comment 1.

Output:
$ g++-5-20150125 -std=c++11 -o test62258 test62258.c -Wall && ./test62258
test62258: test62258.c:11: int main(): Assertion `!std::uncaught_exception()' failed.
Aborted

$ g++-5-20150125 -v
Using built-in specs.
COLLECT_GCC=g++-5-20150125
COLLECT_LTO_WRAPPER=/home/user/gcc50/bin/../libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/user/gcc50build/src-gcc-5-20150125/configure --target=x86_64-unknown-linux-gnu --prefix=/home/user/gcc50build/target-x86_64-unknown-linux-gnu --program-suffix=-5-20150125 --disable-nls --enable-c99 --enable-checking=release --enable-gnu-unique-object --enable-gold --enable-languages=c,c++ --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-linker-build-id --enable-long-long --enable-multiarch --enable-multilib --enable-shared --enable-targets=all --enable-threads=posix --with-system-zlib --with-tune=generic
Thread model: posix
gcc version 5.0.0 20150125 (experimental) (GCC)

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.9/+bug/1439451/comments/7

------------------------------------------------------------------------
On 2015-02-06T10:04:11+00:00 M-kwiatkowski wrote:

Created attachment 34683
Workaround code

For all programmers out there that may encounter this bug, I attach a
workaround code.

Linking your program with it should make rethrow_exception() usable even
if the library on the system is buggy.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.9/+bug/1439451/comments/8

------------------------------------------------------------------------
On 2015-02-06T19:50:39+00:00 Public-n wrote:

A few days ago I submitted a patch for this issue based on Dmitry's
patch. It seems as if we can get it in after the 5.0 release.

https://gcc.gnu.org/ml/gcc-patches/2015-02/msg00027.html

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.9/+bug/1439451/comments/9


** Changed in: gcc
       Status: Unknown => Confirmed

** Changed in: gcc
   Importance: Unknown => Medium

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-4.9 in Ubuntu.
https://bugs.launchpad.net/bugs/1439451

Title:
  std::uncaught_exception() returns true after catching an exception
  thrown with std::rethrow_exception

Status in The GNU Compiler Collection:
  Confirmed
Status in gcc-4.9 package in Ubuntu:
  New

Bug description:
  See attached testcase.

  On debugging, it seems that std::rethrow_exception isn't incrementing
  __cxa_get_globals()->uncaughtExceptions, so when the exception is
  caught it's decremented from 0 to MAXINT.

  ProblemType: Bug
  DistroRelease: Ubuntu 15.04
  Package: libstdc++6 4.9.2-10ubuntu12
  ProcVersionSignature: Ubuntu 3.19.0-10.10-generic 3.19.2
  Uname: Linux 3.19.0-10-generic x86_64
  ApportVersion: 2.17-0ubuntu1
  Architecture: amd64
  CurrentDesktop: Unity
  Date: Thu Apr  2 10:50:37 2015
  Dependencies:
   gcc-4.9-base 4.9.2-10ubuntu12
   gcc-5-base 5-20150328-0ubuntu2
   libc6 2.21-0ubuntu4
   libgcc1 1:5-20150328-0ubuntu2
   multiarch-support 2.21-0ubuntu4
  InstallationDate: Installed on 2013-08-06 (603 days ago)
  InstallationMedia: Ubuntu 13.04 "Raring Ringtail" - Release amd64 (20130424)
  SourcePackage: gcc-4.9
  UpgradeStatus: Upgraded to vivid on 2013-08-06 (603 days ago)

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/1439451/+subscriptions



More information about the foundations-bugs mailing list