public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/64241] New: make_exception_ptr returns garbage with -fno-exceptions
Date: Tue, 09 Dec 2014 15:26:00 -0000	[thread overview]
Message-ID: <bug-64241-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64241

            Bug ID: 64241
           Summary: make_exception_ptr returns garbage with
                    -fno-exceptions
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org

#include <exception>

int main()
{
  std::exception_ptr p = std::make_exception_ptr(1);
  if (!p)
    return 1;
}

g++  ex.cc -fno-exceptions -std=c++11 && valgrind ./a.out

==18255== Memcheck, a memory error detector
==18255== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==18255== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==18255== Command: ./a.out
==18255== 
==18255== Conditional jump or move depends on uninitialised value(s)
==18255==    at 0x40066A: main (in /tmp/a.out)
==18255== 
==18255== Conditional jump or move depends on uninitialised value(s)
==18255==    at 0x394C85EB3A: std::__exception_ptr::exception_ptr::_M_release()
(eh_ptr.cc:86)
==18255==    by 0x40068A: main (in /tmp/a.out)
==18255== 
==18255== Use of uninitialised value of size 8
==18255==    at 0x394C85EB3C: std::__exception_ptr::exception_ptr::_M_release()
(eh_ptr.cc:90)
==18255==    by 0x40068A: main (in /tmp/a.out)
==18255== 
==18255== 
==18255== Process terminating with default action of signal 11 (SIGSEGV):
dumping core
==18255==  Bad permissions for mapped region at address 0x400670
==18255==    at 0x394C85EB3C: std::__exception_ptr::exception_ptr::_M_release()
(eh_ptr.cc:90)
==18255==    by 0x40068A: main (in /tmp/a.out)
==18255== 
==18255== HEAP SUMMARY:
==18255==     in use at exit: 0 bytes in 0 blocks
==18255==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==18255== 
==18255== All heap blocks were freed -- no leaks are possible
==18255== 
==18255== For counts of detected and suppressed errors, rerun with: -v
==18255== Use --track-origins=yes to see where uninitialised values come from
==18255== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 2 from 2)
Segmentation fault

We don't return anything when exceptions are disabled:

  template<typename _Ex>
    exception_ptr 
    make_exception_ptr(_Ex __ex) _GLIBCXX_USE_NOEXCEPT
    {
      __try
    {
#ifdef __EXCEPTIONS
      throw __ex;
#endif
    }
      __catch(...)
    {
      return current_exception();
    }
    }

We should probably just return a default-constructed object.


             reply	other threads:[~2014-12-09 15:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-09 15:26 redi at gcc dot gnu.org [this message]
2014-12-12 15:10 ` [Bug libstdc++/64241] " redi at gcc dot gnu.org
2014-12-12 16:09 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-64241-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).