Thanks. No question, that concerns me.

I don't do any explicit new's in any of the processing I detail below. Does the 
C++ library do a new or malloc() under the covers? Who knows. Do I use stack? 
Of course. I suppose one advantage of throwing an exception would be that it 
would free up stack. I would need to call the dump first and after that we are 
home free anyway.

Worst case we blow up at some point and frankly I'm not much worse off than I 
was with the bad_alloc exception.

In my test it is one 6.3MB new that fails. So I presumably have lots of spare 
heap; just not 6.3MB. If the failure were due to a loop that did lots of tiny 
new's then that would not be the case. If the loop involved recursion I might 
be out of stack.

One of the major chores my terminate routine does is lots and lots of delete's, 
so that would presumably free up heap.

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of Carl Kugler
Sent: Friday, January 23, 2015 11:12 AM
To: [email protected]
Subject: Re: In C++ any way to get traceback info in a catch()?

On Fri, 23 Jan 2015 10:50:50 -0800, Charles Mills <[email protected]> wrote:

>Works like a champ! That is exactly what David Crayford (thank you, 
>David!) suggested off-line. I followed the spirit of this, but did 
>things somewhat differently. In my new handler, I
>
>- Put out a diagnostic message
>- Call CEE3DMP
>- Call my existing clean-up-and-terminate routine.
>

It seems to me that you have to be careful not to do too much in your new 
handler, because, depending on the size of the new() that failed, you might 
have very little HEAP or STACK space to work with. One way around that might be 
to new() a reserve buffer before calling set_new_handler() and then freeing 
that reserve buffer in your new handler.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to