Re: C++/Operator new/Exception :St9exception

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

 



Alright. I made a typo. The original code actually was:

OLD:
	try {
		Example_class *ec = new Example_class();
	 } catch (exception e) {	//caught by value
		cout << e.what();
	 }

In the new code, I just changed it to catch by reference.
NEW:
	try {
		Example_class *ec = new Example_class();
	} catch(exception &e)	{
		cout << e.what();
	}

I got a St9bad_alloc. Thats pretty much reasonable. My problem is 
resolved.


On Fri, 12 Sep 2008, Anitha Boyapati wrote:

> 
> Hi,
> 
> Can somebody please throw light on "St9exception" being thrown during 
> "new" operation ?
> 
> I cannot put the source code here. Its simply huge. And it is not getting 
> reproduced in smaller cases either. Here is a small description:
> 
> //ALERT: NOT A TESTCASE!
> 
> 	try {
> 		Example_class *ec = new Example_class()
> 	} catch(exception &e) {
> 		cout << e.what();
> 	}
> 
> Somewhat euivalent code is given above. The output is St9exception. 
> Example_class object gets constructed atleast 1 million times in my 
> application successfully before it gives out an abort message from 
> operator new.
> 
> #0  0x007587a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
> #1  0x0079c7d5 in raise () from /lib/tls/libc.so.6
> #2  0x0079e149 in abort () from /lib/tls/libc.so.6
> #3  0x004f5557 in __cxa_call_unexpected () from /usr/lib/libstdc++.so.5
> #4  0x004f55a4 in std::terminate () from /usr/lib/libstdc++.so.5
> #5  0x004f5716 in __cxa_throw () from /usr/lib/libstdc++.so.5
> #6  0x004f5972 in operator new () from /usr/lib/libstdc++.so.5
> 
> However at some point of time, when the application size really bulges out 
> consuming 3.8GB of virtual memory, this exception is thrown and 
> application is aborted [The application is a simulator, so it runs for 
> quite a while]
> 
> Now I would have been happy for a std::bad_alloc exception, but not with 
> this St9exception. I can almost (ofcourse not 100% sure which is why I am 
> here) say that there are no logical bugs or corrupted memories being 
> accessed. Even if there are, a SIGSEGV should have been thrown instead of 
> a SIGABRT. 
> 
> Thanks in advance!
> 
> 
> 

-- 
Regards,
Anitha B
@S A N K H Y A


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux