Commit d9e5eaa5 authored by unknown's avatar unknown
Browse files

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

- added proper error message on all failed array pool mallocs

parent a1f9ec01
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ ErrorReporter::setErrorHandlerShutdownType(NdbShutdownType nst)
void childReportError(int error);

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];

@@ -179,10 +179,10 @@ ErrorReporter::handleAssert(const char* message, const char* file, int line)
  BaseString::snprintf(refMessage, 100, "%s line: %d (block: %s)",
	   file, line, blockName);
#endif
  WriteMessage(NDBD_EXIT_PRGERR, message, refMessage,
  WriteMessage(ec, message, refMessage,
	       theEmulatedJamIndex, theEmulatedJam);

  childReportError(NDBD_EXIT_PRGERR);
  childReportError(ec);

  NdbShutdown(s_errorHandlerShutdownType);
}
+2 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define ERRORREPORTER_H

#include <ndb_global.h>
#include <ndbd_exit_codes.h>

#include "TimeModule.hpp"
#include <Emulator.hpp>
@@ -28,7 +29,7 @@ public:
  static void setErrorHandlerShutdownType(NdbShutdownType nst = NST_ErrorHandler);
  static void handleAssert(const char* message, 
			   const char* file, 
			   int line);
			   int line, int ec = NDBD_EXIT_PRGERR);
  
  static void handleError(int faultID, 
			  const char* problemData,
+14 −4
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ public:
   *
   * Note, can currently only be called once
   */
  bool setSize(Uint32 noOfElements);
  bool setSize(Uint32 noOfElements, bool exit_on_error = true);

  inline Uint32 getNoOfFree() const {
    return noOfFree;
@@ -218,13 +218,19 @@ ArrayPool<T>::~ArrayPool(){
template <class T>
inline
bool
ArrayPool<T>::setSize(Uint32 noOfElements){
ArrayPool<T>::setSize(Uint32 noOfElements, bool exit_on_error){
  if(size == 0){
    if(noOfElements == 0)
      return true;
    theArray = (T *)NdbMem_Allocate(noOfElements * sizeof(T));
    if(theArray == 0)
    {
      if (!exit_on_error)
	return false;
      ErrorReporter::handleAssert("ArrayPool<T>::setSize malloc failed",
				  __FILE__, __LINE__, NDBD_EXIT_MEMALLOC);
      return false; // not reached
    }
    size = noOfElements;
    noOfFree = noOfElements;

@@ -247,7 +253,11 @@ ArrayPool<T>::setSize(Uint32 noOfElements){
    
    return true;
  }
  if (!exit_on_error)
    return false;

  ErrorReporter::handleAssert("ArrayPool<T>::setSize called twice", __FILE__, __LINE__);
  return false; // not reached
}
  
template <class T>
+9 −3
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ public:
   *
   * Note, can currently only be called once
   */
  bool setSize(Uint32 noOfElements);
  bool setSize(Uint32 noOfElements, bool exit_on_error = true);

  /**
   * Get size
@@ -82,13 +82,19 @@ CArray<T>::~CArray(){
template <class T>
inline
bool
CArray<T>::setSize(Uint32 noOfElements){
CArray<T>::setSize(Uint32 noOfElements, bool exit_on_error){
  if(size == noOfElements)
    return true;
  
  theArray = (T *)NdbMem_Allocate(noOfElements * sizeof(T));
  if(theArray == 0)
  {
    if (!exit_on_error)
      return false;
    ErrorReporter::handleAssert("CArray<T>::setSize malloc failed",
				__FILE__, __LINE__, NDBD_EXIT_MEMALLOC);
    return false; // not reached
  }
  size = noOfElements;
  return true;
}
+2 −2
Original line number Diff line number Diff line
@@ -25,8 +25,8 @@ SafeCounterManager::SafeCounterManager(class SimulatedBlock & block)
{}
  
bool
SafeCounterManager::setSize(Uint32 maxNoOfActiveMutexes) {
  return m_counterPool.setSize(maxNoOfActiveMutexes);
SafeCounterManager::setSize(Uint32 maxNoOfActiveMutexes, bool exit_on_error) {
  return m_counterPool.setSize(maxNoOfActiveMutexes, exit_on_error);
}

Uint32
Loading