summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorMarc Alff <marc.alff@sun.com>2008-08-11 10:10:00 -0600
committerMarc Alff <marc.alff@sun.com>2008-08-11 10:10:00 -0600
commit5d265802e42bfc27bb96c0e90ba59accfae2134b (patch)
tree00128c7f6950718686575844b6b79b9f0322fdc1 /mysys
parent133557c131c036083e7d66b27ec71c722b398b5b (diff)
downloadmariadb-git-5d265802e42bfc27bb96c0e90ba59accfae2134b.tar.gz
Bug#38296 (low memory crash with many conditions in a query)
This fix is for 5.0 only : back porting the 6.0 patch manually The parser code in sql/sql_yacc.yy needs to be more robust to out of memory conditions, so that when parsing a query fails due to OOM, the thread gracefully returns an error. Before this fix, a new/alloc returning NULL could: - cause a crash, if dereferencing the NULL pointer, - produce a corrupted parsed tree, containing NULL nodes, - alter the semantic of a query, by silently dropping token values or nodes With this fix: - C++ constructors are *not* executed with a NULL "this" pointer when operator new fails. This is achieved by declaring "operator new" with a "throw ()" clause, so that a failed new gracefully returns NULL on OOM conditions. - calls to new/alloc are tested for a NULL result, - The thread diagnostic area is set to an error status when OOM occurs. This ensures that a request failing in the server properly returns an ER_OUT_OF_RESOURCES error to the client. - OOM conditions cause the parser to stop immediately (MYSQL_YYABORT). This prevents causing further crashes when using a partially built parsed tree in further rules in the parser. No test scripts are provided, since automating OOM failures is not instrumented in the server. Tested under the debugger, to verify that an error in alloc_root cause the thread to returns gracefully all the way to the client application, with an ER_OUT_OF_RESOURCES error.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_alloc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index 5983a29a3e1..99b5aec7eea 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -202,7 +202,7 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
{
if (mem_root->error_handler)
(*mem_root->error_handler)();
- return((gptr) 0); /* purecov: inspected */
+ DBUG_RETURN((gptr) 0); /* purecov: inspected */
}
mem_root->block_num++;
next->next= *prev;