forked from OSchip/llvm-project
431502a675
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". There are calls to C allocation functions, malloc, calloc and realloc. They are used for interoperability with C code, when allocated object has variable size and when it is necessary to avoid call of constructors. In many calls the result is not checked against null pointer. To simplify checks, new functions are defined in the namespace 'llvm' with the same names as these C function. These functions produce fatal error if allocation fails. User should use 'llvm::malloc' instead of 'std::malloc' in order to use the safe variant. This change replaces 'std::malloc' in the cases when the result of allocation function is not checked against null pointer. Finally, there are plain C code, that uses malloc and similar functions. If the result is not checked, assert statements are added. Differential Revision: https://reviews.llvm.org/D43010 llvm-svn: 325224 |
||
---|---|---|
.. | ||
DynamicLibrary | ||
ARMAttributeParser.cpp | ||
AlignOfTest.cpp | ||
AllocatorTest.cpp | ||
ArrayRecyclerTest.cpp | ||
BinaryStreamTest.cpp | ||
BlockFrequencyTest.cpp | ||
BranchProbabilityTest.cpp | ||
CMakeLists.txt | ||
CachePruningTest.cpp | ||
Casting.cpp | ||
Chrono.cpp | ||
CommandLineTest.cpp | ||
CompressionTest.cpp | ||
ConvertUTFTest.cpp | ||
CrashRecoveryTest.cpp | ||
DataExtractorTest.cpp | ||
DebugTest.cpp | ||
EndianStreamTest.cpp | ||
EndianTest.cpp | ||
ErrnoTest.cpp | ||
ErrorOrTest.cpp | ||
ErrorTest.cpp | ||
FileOutputBufferTest.cpp | ||
FormatVariadicTest.cpp | ||
GlobPatternTest.cpp | ||
Host.cpp | ||
LEB128Test.cpp | ||
LineIteratorTest.cpp | ||
LockFileManagerTest.cpp | ||
MD5Test.cpp | ||
ManagedStatic.cpp | ||
MathExtrasTest.cpp | ||
MemoryBufferTest.cpp | ||
MemoryTest.cpp | ||
NativeFormatTests.cpp | ||
ParallelTest.cpp | ||
Path.cpp | ||
ProcessTest.cpp | ||
ProgramTest.cpp | ||
RegexTest.cpp | ||
ReplaceFileTest.cpp | ||
ReverseIterationTest.cpp | ||
ScaledNumberTest.cpp | ||
SourceMgrTest.cpp | ||
SpecialCaseListTest.cpp | ||
StringPool.cpp | ||
SwapByteOrderTest.cpp | ||
TarWriterTest.cpp | ||
TargetParserTest.cpp | ||
ThreadLocalTest.cpp | ||
ThreadPool.cpp | ||
Threading.cpp | ||
TimerTest.cpp | ||
TrailingObjectsTest.cpp | ||
TrigramIndexTest.cpp | ||
TypeNameTest.cpp | ||
UnicodeTest.cpp | ||
YAMLIOTest.cpp | ||
YAMLParserTest.cpp | ||
formatted_raw_ostream_test.cpp | ||
raw_ostream_test.cpp | ||
raw_pwrite_stream_test.cpp | ||
raw_sha1_ostream_test.cpp | ||
xxhashTest.cpp |