Bug#11739 SendBufferMemory set to 294967039 causes core where max = 4294967039

- added proper error message on all failed array pool mallocs
parent 6d28e7a6
...@@ -165,7 +165,7 @@ ErrorReporter::setErrorHandlerShutdownType(NdbShutdownType nst) ...@@ -165,7 +165,7 @@ ErrorReporter::setErrorHandlerShutdownType(NdbShutdownType nst)
void childReportError(int error); void childReportError(int error);
void void
ErrorReporter::handleAssert(const char* message, const char* file, int line) ErrorReporter::handleAssert(const char* message, const char* file, int line, int ec)
{ {
char refMessage[100]; char refMessage[100];
...@@ -179,10 +179,10 @@ ErrorReporter::handleAssert(const char* message, const char* file, int line) ...@@ -179,10 +179,10 @@ ErrorReporter::handleAssert(const char* message, const char* file, int line)
BaseString::snprintf(refMessage, 100, "%s line: %d (block: %s)", BaseString::snprintf(refMessage, 100, "%s line: %d (block: %s)",
file, line, blockName); file, line, blockName);
#endif #endif
WriteMessage(NDBD_EXIT_PRGERR, message, refMessage, WriteMessage(ec, message, refMessage,
theEmulatedJamIndex, theEmulatedJam); theEmulatedJamIndex, theEmulatedJam);
childReportError(NDBD_EXIT_PRGERR); childReportError(ec);
NdbShutdown(s_errorHandlerShutdownType); NdbShutdown(s_errorHandlerShutdownType);
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#define ERRORREPORTER_H #define ERRORREPORTER_H
#include <ndb_global.h> #include <ndb_global.h>
#include <ndbd_exit_codes.h>
#include "TimeModule.hpp" #include "TimeModule.hpp"
#include <Emulator.hpp> #include <Emulator.hpp>
...@@ -28,7 +29,7 @@ public: ...@@ -28,7 +29,7 @@ public:
static void setErrorHandlerShutdownType(NdbShutdownType nst = NST_ErrorHandler); static void setErrorHandlerShutdownType(NdbShutdownType nst = NST_ErrorHandler);
static void handleAssert(const char* message, static void handleAssert(const char* message,
const char* file, const char* file,
int line); int line, int ec = NDBD_EXIT_PRGERR);
static void handleError(int faultID, static void handleError(int faultID,
const char* problemData, const char* problemData,
......
...@@ -44,7 +44,7 @@ public: ...@@ -44,7 +44,7 @@ public:
* *
* Note, can currently only be called once * Note, can currently only be called once
*/ */
bool setSize(Uint32 noOfElements); bool setSize(Uint32 noOfElements, bool exit_on_error = true);
inline Uint32 getNoOfFree() const { inline Uint32 getNoOfFree() const {
return noOfFree; return noOfFree;
...@@ -218,13 +218,19 @@ ArrayPool<T>::~ArrayPool(){ ...@@ -218,13 +218,19 @@ ArrayPool<T>::~ArrayPool(){
template <class T> template <class T>
inline inline
bool bool
ArrayPool<T>::setSize(Uint32 noOfElements){ ArrayPool<T>::setSize(Uint32 noOfElements, bool exit_on_error){
if(size == 0){ if(size == 0){
if(noOfElements == 0) if(noOfElements == 0)
return true; return true;
theArray = (T *)NdbMem_Allocate(noOfElements * sizeof(T)); theArray = (T *)NdbMem_Allocate(noOfElements * sizeof(T));
if(theArray == 0) if(theArray == 0)
return false; {
if (!exit_on_error)
return false;
ErrorReporter::handleAssert("ArrayPool<T>::setSize malloc failed",
__FILE__, __LINE__, NDBD_EXIT_MEMALLOC);
return false; // not reached
}
size = noOfElements; size = noOfElements;
noOfFree = noOfElements; noOfFree = noOfElements;
...@@ -247,7 +253,11 @@ ArrayPool<T>::setSize(Uint32 noOfElements){ ...@@ -247,7 +253,11 @@ ArrayPool<T>::setSize(Uint32 noOfElements){
return true; return true;
} }
return false; if (!exit_on_error)
return false;
ErrorReporter::handleAssert("ArrayPool<T>::setSize called twice", __FILE__, __LINE__);
return false; // not reached
} }
template <class T> template <class T>
......
...@@ -31,7 +31,7 @@ public: ...@@ -31,7 +31,7 @@ public:
* *
* Note, can currently only be called once * Note, can currently only be called once
*/ */
bool setSize(Uint32 noOfElements); bool setSize(Uint32 noOfElements, bool exit_on_error = true);
/** /**
* Get size * Get size
...@@ -82,13 +82,19 @@ CArray<T>::~CArray(){ ...@@ -82,13 +82,19 @@ CArray<T>::~CArray(){
template <class T> template <class T>
inline inline
bool bool
CArray<T>::setSize(Uint32 noOfElements){ CArray<T>::setSize(Uint32 noOfElements, bool exit_on_error){
if(size == noOfElements) if(size == noOfElements)
return true; return true;
theArray = (T *)NdbMem_Allocate(noOfElements * sizeof(T)); theArray = (T *)NdbMem_Allocate(noOfElements * sizeof(T));
if(theArray == 0) if(theArray == 0)
return false; {
if (!exit_on_error)
return false;
ErrorReporter::handleAssert("CArray<T>::setSize malloc failed",
__FILE__, __LINE__, NDBD_EXIT_MEMALLOC);
return false; // not reached
}
size = noOfElements; size = noOfElements;
return true; return true;
} }
......
...@@ -25,8 +25,8 @@ SafeCounterManager::SafeCounterManager(class SimulatedBlock & block) ...@@ -25,8 +25,8 @@ SafeCounterManager::SafeCounterManager(class SimulatedBlock & block)
{} {}
bool bool
SafeCounterManager::setSize(Uint32 maxNoOfActiveMutexes) { SafeCounterManager::setSize(Uint32 maxNoOfActiveMutexes, bool exit_on_error) {
return m_counterPool.setSize(maxNoOfActiveMutexes); return m_counterPool.setSize(maxNoOfActiveMutexes, exit_on_error);
} }
Uint32 Uint32
......
...@@ -63,7 +63,7 @@ class SafeCounterManager { ...@@ -63,7 +63,7 @@ class SafeCounterManager {
public: public:
SafeCounterManager(class SimulatedBlock &); SafeCounterManager(class SimulatedBlock &);
bool setSize(Uint32 maxNoOfActiveMutexes); bool setSize(Uint32 maxNoOfActiveMutexes, bool exit_on_error = true);
Uint32 getSize() const ; Uint32 getSize() const ;
void execNODE_FAILREP(Signal*); void execNODE_FAILREP(Signal*);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment