summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
authorNisha Gopalakrishnan <nisha.gopalakrishnan@oracle.com>2013-01-15 15:30:26 +0530
committerNisha Gopalakrishnan <nisha.gopalakrishnan@oracle.com>2013-01-15 15:30:26 +0530
commitd01b5c392ceed32f4d9a34eec13be4fdd78c1ef6 (patch)
treec177ff5163e51c6d1c8953eeb892c7cc47ca220a /sql/sql_class.cc
parentf7f21ee732acf386745ec9e70c536f51e8871bf0 (diff)
downloadmariadb-git-d01b5c392ceed32f4d9a34eec13be4fdd78c1ef6.tar.gz
Bug#11757464:SERVER CRASH IN RECURSIVE CALL WHEN OOM
Analysis: --------- When the server is out of memory, an error is raised to indicate the same. Handling the error requires more memory to be allocated which fails, hence the error handling loops in a recursion and causes the server to crash. Fix: --- a) Prevents pushing the 'out of memory' error condition to the diagnostic area as it requires memory allocation. GET DIAGNOSTICS, SHOW WARNINGS and SHOW ERRORS statements will not show information about this error. However the 'out of memory' error is returned to the client. b) It sets the ME_FATALERROR flag when 'out of memory' errors are reported (for places where the flag is not already set). This flag prevents activation of SP error handlers which also require memory allocation and therefore are likely to fail.
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 6e47dcb5795..556e7d66447 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1136,10 +1136,14 @@ MYSQL_ERROR* THD::raise_condition(uint sql_errno,
query_cache_abort(&query_cache_tls);
- /* When simulating OOM, skip writing to error log to avoid mtr errors */
- DBUG_EXECUTE_IF("simulate_out_of_memory", DBUG_RETURN(NULL););
-
- cond= warning_info->push_warning(this, sql_errno, sqlstate, level, msg);
+ /*
+ Avoid pushing a condition for out of memory errors as this will require
+ memory allocation and therefore might fail.
+ */
+ if (sql_errno != EE_OUTOFMEMORY && sql_errno != ER_OUTOFMEMORY)
+ {
+ cond= warning_info->push_warning(this, sql_errno, sqlstate, level, msg);
+ }
DBUG_RETURN(cond);
}
@@ -1938,7 +1942,7 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, long key_length)
key_length + 1);
if (!new_table)
{
- my_error(EE_OUTOFMEMORY, MYF(ME_BELL),
+ my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_FATALERROR),
ALIGN_SIZE(sizeof(TABLE_LIST)) + key_length + 1);
killed= KILL_CONNECTION;
return 0;
@@ -2493,7 +2497,7 @@ bool select_export::send_data(List<Item> &items)
set_if_smaller(estimated_bytes, UINT_MAX32);
if (cvt_str.realloc((uint32) estimated_bytes))
{
- my_error(ER_OUTOFMEMORY, MYF(0), (uint32) estimated_bytes);
+ my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), (uint32) estimated_bytes);
goto err;
}