Attempt to log before terminating if prevector allocation fails
This commit is contained in:
14
src/init.cpp
14
src/init.cpp
@@ -723,20 +723,6 @@ bool AppInitServers(boost::thread_group& threadGroup)
|
||||
return true;
|
||||
}
|
||||
|
||||
[[noreturn]] static void new_handler_terminate()
|
||||
{
|
||||
// Rather than throwing std::bad-alloc if allocation fails, terminate
|
||||
// immediately to (try to) avoid chain corruption.
|
||||
// Since LogPrintf may itself allocate memory, set the handler directly
|
||||
// to terminate first.
|
||||
std::set_new_handler(std::terminate);
|
||||
fputs("Error: Out of memory. Terminating.\n", stderr);
|
||||
LogPrintf("Error: Out of memory. Terminating.\n");
|
||||
|
||||
// The log was successful, terminate now.
|
||||
std::terminate();
|
||||
};
|
||||
|
||||
/** Initialize bitcoin.
|
||||
* @pre Parameters should be parsed and config file should be read.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user