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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2016-04-20
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.

unwind-dw2-fde.c does

static inline int
start_fde_sort (struct fde_accumulator *accu, size_t count)
{
  size_t size;
  if (! count)
    return 0;

  size = sizeof (struct fde_vector) + sizeof (const fde *) * count;
  if ((accu->linear = malloc (size)))
    {
      accu->linear->count = 0;
      if ((accu->erratic = malloc (size)))
        accu->erratic->count = 0;
      return 1;
    }
  else
    return 0;
}

via

#0  search_object (ob=ob@entry=0x80fafa4 <object>, 
    pc=pc@entry=0x80563ee <_Unwind_RaiseException+46>)
    at /space/rguenther/src/svn/gcc-5-branch/libgcc/unwind-dw2-fde.c:966
#1  0x08058275 in _Unwind_Find_registered_FDE (bases=0xffdfa7d4, 
    pc=0x80563ee <_Unwind_RaiseException+46>)
    at /space/rguenther/src/svn/gcc-5-branch/libgcc/unwind-dw2-fde.c:1025
#2  _Unwind_Find_FDE (pc=0x80563ee <_Unwind_RaiseException+46>, 
    bases=0xffdfa7d4)
    at /space/rguenther/src/svn/gcc-5-branch/libgcc/unwind-dw2-fde-dip.c:448
#3  0x08054bf3 in uw_frame_state_for (context=context@entry=0xffdfa780, 
    fs=fs@entry=0xffdfa690)
    at /space/rguenther/src/svn/gcc-5-branch/libgcc/unwind-dw2.c:1241
#4  0x08055c76 in uw_init_context_1 (context=context@entry=0xffdfa780, 
    outer_cfa=outer_cfa@entry=0xffdfa960, outer_ra=
    0x804aac4 <__cxxabiv1::__cxa_throw(void*, std::type_info*, void
(*)(void*))+100>) at
/space/rguenther/src/svn/gcc-5-branch/libgcc/unwind-dw2.c:1562
#5  0x080563ef in _Unwind_RaiseException (exc=0x8835d78)
    at /space/rguenther/src/svn/gcc-5-branch/libgcc/unwind.inc:88
#6  0x0804aac4 in __cxxabiv1::__cxa_throw (obj=0x8835d98, 
    tinfo=0x80f9df4 <typeinfo for std::bad_alloc>, 
    dest=0x80490b0 <std::bad_alloc::~bad_alloc()>)
    at
/space/rguenther/src/svn/gcc-5-branch/libstdc++-v3/libsupc++/eh_throw.cc:82

but it's just trying to sort the FDE - if it fails to allocate the memory
required for that (glibc does quite a few mmap calls for that attempt) it
continues w/o sorting the FDE but then eventually properly unwinds and throws.

If I add a printf to print k to show how many times foo is called before
throwing then I see

> ./a.out
9682
9684
9686
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted

for the dynamically linked case and

> ./a.out
14626
14628
14630
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted

for the statically linked case.  I think thats a reasonable result and thus
I think there is no bug.

Reply via email to