Michael Kilburn
2017-08-15 07:33:08 UTC
Hi,
I have discovered recently that "throw X(...);" terminates application if
it can't allocate memory for exception being thrown. This happens with GCC.
Standard does not specify what should happen in this situation (see C++11
15.1.p4).
I am trying to discuss this situation with someone who is closer to
committee than me... Is it a defect? Standard does not specify behavior
here and implementations are free to terminate (and they do) -- problem is
that this makes impossibly to write a C++ program that survives
out-of-memory situation -- even throwing std::bad_alloc can terminate your
app.
If it isn't a defect -- how to write such program?
I've investigated GCC and apparently it can even hang your application in
this case (deadlock) if you are unlucky enough. If you are interested,
details are here:
https://stackoverflow.com/questions/45497684/what-happens-if-throw-fails-to-allocate-memory-for-exception-object/45552806#45552806
If I am wrong somewhere -- I'd appreciate if my mistake is pointed out.
Thank you,
Michael.
I have discovered recently that "throw X(...);" terminates application if
it can't allocate memory for exception being thrown. This happens with GCC.
Standard does not specify what should happen in this situation (see C++11
15.1.p4).
I am trying to discuss this situation with someone who is closer to
committee than me... Is it a defect? Standard does not specify behavior
here and implementations are free to terminate (and they do) -- problem is
that this makes impossibly to write a C++ program that survives
out-of-memory situation -- even throwing std::bad_alloc can terminate your
app.
If it isn't a defect -- how to write such program?
I've investigated GCC and apparently it can even hang your application in
this case (deadlock) if you are unlucky enough. If you are interested,
details are here:
https://stackoverflow.com/questions/45497684/what-happens-if-throw-fails-to-allocate-memory-for-exception-object/45552806#45552806
If I am wrong somewhere -- I'd appreciate if my mistake is pointed out.
Thank you,
Michael.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.