[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: C++ exception handling question



On 11/6/06, Paul E Condon <pecondon@mesanetworks.net> wrote:
Thanks for stack profiling info. I wonder if this _is_ a reportable
bug. After all, there is a lot of information on the 'bad_alloc'
exception in various sources. If GNU C++ library doesn't try to throw
this exception until it is too late for the throw to succeed, what
good is it? And, how was its operation verified during testing on a
Debain box? At the point where it kill happens, I think the program
is allocating space for the contents of large STL vector of vectors.
It doesn't seem to me that this should be done on the stack, but I
haven't thought deeply on the issue.

That's easy enough to test:

#include <iostream>

int main()
{
  try
  {
     while(1)
     {
        int* p = new int[1000000];
     }
  }
  catch ( ... )
  {
     std::cout << "caught one" << std::endl;
  }
  return 0;
}

Running in a shell with "ulimit -d 2000 -s 2000" I get an exception
caught successfully.  That's with g++ 3.2.3.

--
Michael A. Marsh
http://www.umiacs.umd.edu/~mmarsh
http://mamarsh.blogspot.com



Reply to: