0024836: Stack overflow when raising exception in low memory condition
authorabv <abv@opencascade.com>
Thu, 7 Jan 2016 07:02:16 +0000 (10:02 +0300)
committerabv <abv@opencascade.com>
Thu, 21 Jan 2016 12:49:51 +0000 (15:49 +0300)
commit4db4247a0b7d5f9c9128feca974eea213547af19
tree10ab73a5a9522ef872971a9b4f156e8a87f98e41
parente085d8a60efeeda00d73cba502e2ba34799765c6
0024836: Stack overflow when raising exception in low memory condition

Standard_OutOfMemory exception is refactored so as to avoid memory allocations (which will likely fail) when it is raised:

- method NewInstance() returns static instance (singleton)
- method Raise() raises copy of that singleton, resetting its message string
- message string is stored as field, not allocated dynamically (thus maximum message length is limited by buffer size)

Class Standard_Failure slightly revised: method Destroy() is merged to destructor, methods Get/SetMessageString() are made virtual.

Add test case for the bug
src/NCollection/NCollection_WinHeapAllocator.cxx
src/QABugs/QABugs_20.cxx
src/Standard/FILES
src/Standard/Standard_Failure.cxx
src/Standard/Standard_Failure.hxx
src/Standard/Standard_Failure.lxx [deleted file]
src/Standard/Standard_MMgrOpt.cxx
src/Standard/Standard_OutOfMemory.cxx [new file with mode: 0644]
src/Standard/Standard_OutOfMemory.hxx
tests/bugs/fclasses/bug24836 [new file with mode: 0644]