1. streambuf::underflow dislikes exceptions
I'm writing a streambuf, but I'm having some problems with handling
errors. My streambuf may fail in underflow, and according to the C++
standard draft (jan 96), that can be handled by throwing an exception:
12) undeflow or uflow might fail by throwing an exception
The intention is not only that the calls will not return eof()
that they will return ``immediately.''
The problem is that my program dumps core if I throw an exception in
Here's the stack trace:
#0 0x400a6d41 in __kill () from /lib/libc.so.6
#1 0x400a69b6 in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2 0x400a80d8 in abort () at ../sysdeps/generic/abort.c:88
#3 0x40057e55 in __default_terminate () from
#4 0x40057e72 in __terminate () from /usr/lib/libstdc++-libc6.1-1.so.2
#5 0x4005875b in __throw () from /usr/lib/libstdc++-libc6.1-1.so.2
#6 0x804a8fd in fcol::mystreambuf::underflow () at mystreambuf.cpp:63
#7 0x400debcc in __underflow (fp=0x8055568) at genops.c:303
#8 0x400dee83 in _IO_default_xsgetn (fp=0x8055568, data=0xbffff89a,
n=1) at genops.c:472
#9 0x40052242 in streambuf::xsgetn (this=0x8055568, s=0xbffff89a
#10 0x400df1f6 in _IO_sgetn (fp=0x8055568, data=0xbffff89a, n=1) at
#11 0x4004d641 in istream::read (this=0xbffff8a4, s=0xbffff89a
#12 0x804a23f in main () at test_imystream.cpp:25
It seems that #10, #8 and #7 are functions written in C. Is it ok for a
C++ (member) function to throw an exception, if it is called by a C
function, that is called by a C++ (member) function, that catches the
exception? Any other ideas as to why this may be happening? I'll e glad
to provide more detailed information upon request.
I'm using gcc (egcs-2.91.66).
2. Palm III on Ebay, like new!
3. Throwing exceptions in dtors called by thrown exceptions
4. Switch from Schedule Plus to Outlook 98?
5. Derived Class function throwing exceptions
6. need info about Synopsys chip synthesis workshops
7. Streambuf uflow() vs underflow()
8. Official IBM notice re FixPak 16
9. C++ Exceptions: throw vs. throw new
10. Exceptions are good...but to throw or not to throw is the problem
11. Exception Objects Throwing Exceptions.
12. Exception while throwing an exception?
13. Overflow, underflow, and exceptions