[LLVMbugs] [Bug 13669] New: std::uncaught_exception should not call abort() if __cxa_uncaught_exception is unavailable
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Aug 22 13:06:43 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13669
Bug #: 13669
Summary: std::uncaught_exception should not call abort() if
__cxa_uncaught_exception is unavailable
Product: libc++
Version: unspecified
Platform: All
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
AssignedTo: hhinnant at apple.com
ReportedBy: oneill+llvmbugs at cs.hmc.edu
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 9097
--> http://llvm.org/bugs/attachment.cgi?id=9097
Return false rather than abort.
On Linux, I found libc++ was crashing in basic_ostream<_CharT,
_Traits>::sentry::~sentry(). I tracked down the source of the problem to the
fact that this function calls std::uncaught_exception(), and apparently
std::uncaught_exception() calls abort().
This seems to be wrong on two counts. With the GNU C++ abi on Linux there
apparently *is* a way to find out if there are uncaught exceptions; with the
GNU ABI, it appears that
return __cxa_get_globals()->uncaughtExceptions != 0;
would do the trick, but for that to work, you need the necessary declarations
for the GNU version of ABI. An alternative would be to consider
std::uncaught_exception a GNU ABI function (since these days it's part of the
source for libsupc++) and just have std::__1::uncaught_exception call
std::uncaught_exception.
A workable bandaid for the problem would be to just use
return false;
This solution (while wrong) is far less wrong than unconditionally aborting,
since the number of programs that abort now drops to a tiny fraction of those
that would have aborted before.
An even better solution would be to have coherent instructions for building
libc++abi and libc++ together on Linux.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list