diff options
| author | Serge Pavlov <sepavloff@gmail.com> | 2018-02-17 10:21:33 +0000 |
|---|---|---|
| committer | Serge Pavlov <sepavloff@gmail.com> | 2018-02-17 10:21:33 +0000 |
| commit | d48042efa831f8f9bde7bf88585eb5b02565b718 (patch) | |
| tree | 9d2e9412d91fec2591f9a422d451204570460027 /llvm/include | |
| parent | b51a9bc35854509b9d4b125d232c4ff07ab765f5 (diff) | |
| download | bcm5719-llvm-d48042efa831f8f9bde7bf88585eb5b02565b718.tar.gz bcm5719-llvm-d48042efa831f8f9bde7bf88585eb5b02565b718.zip | |
Report fatal error in the case of out of memory
This is partial recommit of r325224, reverted in 325227. The relevant
part of original comment is below.
Analysis of fails in the case of out of memory errors can be tricky on
Windows. Such error emerges at the point where memory allocation function
fails, but manifests itself when null pointer is used. These two points
may be distant from each other. Besides, next runs may not exhibit
allocation error.
Usual programming practice does not require checking result of 'operator
new' because it throws 'std::bad_alloc' in the case of allocation error.
However, LLVM is usually built with exceptions turned off, so 'new' can
return null pointer. This change installs custom new handler, which causes
fatal error in the case of out of memory. The handler is installed
automatically prior to call to 'main' during construction of a static
object defined in 'lib/Support/ErrorHandling.cpp'. If the application does
not use this file, the handler may be installed manually by a call to
'llvm::install_out_of_memory_new_handler', declared in
'include/llvm/Support/ErrorHandling.h".
Differential Revision: https://reviews.llvm.org/D43010
llvm-svn: 325426
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/Support/ErrorHandling.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/ErrorHandling.h b/llvm/include/llvm/Support/ErrorHandling.h index acd89873328..39cbfed2436 100644 --- a/llvm/include/llvm/Support/ErrorHandling.h +++ b/llvm/include/llvm/Support/ErrorHandling.h @@ -100,6 +100,8 @@ void install_bad_alloc_error_handler(fatal_error_handler_t handler, /// Restores default bad alloc error handling behavior. void remove_bad_alloc_error_handler(); +void install_out_of_memory_new_handler(); + /// Reports a bad alloc error, calling any user defined bad alloc /// error handler. In contrast to the generic 'report_fatal_error' /// functions, this function is expected to return, e.g. the user |

