Bug #27860 parser doesn't handle memory well for large queries. crashes server
Submitted: 16 Apr 2007 20:04 Modified: 7 Nov 2007 11:09
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:5.0BK OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: crash, Memory, parser

[16 Apr 2007 20:04] Shane Bester
Description:
When creating a relatively large stored procedure (17MB in this case), the server crashes during parsing.  This happens on Linux and Windows platforms.

Below is the stack trace:

mysqld-debug.exe!MYSQLparse
mysqld-debug.exe!mysql_parse
mysqld-debug.exe!dispatch_command
mysqld-debug.exe!do_command
mysqld-debug.exe!handle_one_connection
mysqld-debug.exe!pthread_start
mysqld-debug.exe!_callthreadstart
mysqld-debug.exe!_threadstart

Crash line is here:

if (yychar == YYEMPTY)
  i->m_query.length= lex->ptr - sp->m_tmp_query;
else
  i->m_query.length= lex->tok_end - sp->m_tmp_query; <---here
  i->m_query.str= strmake_root(YYTHD->mem_root,
  (char *)sp->m_tmp_query, i->m_query.length);

How to repeat:
run the attached php app.

Suggested fix:
No idea. Improve parser? Perhaps this is a mere feature request.
[16 Apr 2007 20:07] MySQL Verification Team
run testcase. If you have alot of ram and crash doesn't occur, increase 700000 to be higher

Attachment: bug27860.php (application/octet-stream, text), 2.03 KiB.

[16 Apr 2007 20:07] MySQL Verification Team
bug27860_full_stack_5.0.40_windows.txt

Attachment: bug27860_full_stack_5.0.40_windows.txt (text/plain), 783 bytes.

[7 Nov 2007 11:07] Kristofer Pettersson
Situation much improved with patch from Bug#31153. I was unable to reproduce crash with this patch. This is the error message I get running mysqld under ulimit -v 102400:

sqld: Out of memory at line 123, 'array.c'
071107 14:06:16 [ERROR] /home/thek/Development/cpp/bug31153/my50-bug31153/sql/mysqld: needed 25120 byte (25k), memory in use: 4645279 bytes (4537k)