[Bug libstdc++/64535] Emergency buffer for exception allocation too small

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 27 12:23:00 GMT 2015


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

--- Comment #21 from Richard Biener <rguenth at gcc dot gnu.org> ---
We can make it extra-safe but still deallocate in most common cases:

  pool::~pool ()
    {
      __gnu_cxx::__scoped_lock sentry(emergency_mutex);
      if (arena
          && arena == reinterpret_cast <char *> (first_free_entry)
          && arena_size == first_free_entry->size)
        {
          free (arena);
          arena = NULL;
          first_free_entry = NULL;
        }
    }

this ensures threads won't continue allocating from the pool.  Well,
they may in case some other thread frees some exception...  So indeed
running a destructor makes the whole stuff undefined (object lifetime
of the pool ended) :/



More information about the Gcc-bugs mailing list