• unknown's avatar
    Bug #31153 calling stored procedure crashes server if available memory is low · bb681dbc
    unknown authored
    When the server was out of memory it crashed because of invalid memory access.
    
    This patch adds detection for failed memory allocations and make the server
    output a proper error message.
    
    
    sql/mysqld.cc:
      Don't try to push_warning from within push_warning. It will cause a recursion
      until the stack is consumed.
      
      If my_net_init fails (for example: because of OOM) the temporary vio object 
      might have been attached to the thd object already. This will cause a double
      free on the vio object when the thd object is deleted later on and the server
      will crash.
    sql/sp_head.cc:
      Added check for out-of-memory on a 'new' operation.
      Refactored reset_lex method to return a error state code instead of void.
      Initialize the mem-root with init_sql_alloc to get a basic error handler for
      memory allocation problems. This alone won't prevent the server from crashing,
      NULL pointers have to be accounted for as well.
    sql/sp_head.h:
      Use the throw() clause in operator new, to indicate to the compiler that
      memory allocation can fail and return NULL, so that the compiler should
      generate code to check for NULL before invoking C++ constructors, to be
      crash safe.
    sql/sql_base.cc:
      Use init_sql_alloc to get basic out-of-memory error handling.
    sql/sql_lex.h:
      Use the throw() clause in operator new, to indicate to the compiler that
      memory allocation can fail and return NULL, so that the compiler should
      generate code to check for NULL before invoking C++ constructors, to be
      crash safe.
    sql/sql_prepare.cc:
      Use init_sql_alloc to get basic out-of-memory error handling.
    sql/sql_yacc.yy:
      Check for memory allocation failures where it matters.
    bb681dbc
sql_lex.h 42.1 KB