Bug #32020 loading udfs while --skip-grant-tables is enabled causes out of memory errors
Submitted: 1 Nov 2007 8:13 Modified: 28 Nov 2007 23:55
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S3 (Non-critical)
Version:5.0.48, 5.1.23 OS:Any
Assigned to: Alexey Kopytov CPU Architecture:Any
Tags: skip-grant-tables, udf

[1 Nov 2007 8:13] Shane Bester
Description:
when server runs with --skip-grant-tables option, attempting to load a udf (even one that doesn't exist) fails with errors like this:

mysql> CREATE FUNCTION a RETURNS STRING SONAME '';
ERROR 1041 (HY000): Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space

How to repeat:
./bin/mysqld_safe --skip-grant-tables

in client:

CREATE FUNCTION a RETURNS STRING SONAME '';

Suggested fix:
return a reasonable error, and don't try to allocate huge memory when grant tables are not used.
[1 Nov 2007 8:17] Shane Bester
'initialized' variable is zero in mysql_create_function()
[9 Nov 2007 10:29] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/37424

ChangeSet@1.2547, 2007-11-09 13:29:43+03:00, kaa@polly.(none) +3 -0
  Fix for bug #32020: loading udfs while --skip-grant-tables is enabled
  causes out of memory errors
  
  The code in mysql_create_function() and mysql_drop_function() assumed
  that the only reason for UDFs being uninitialized at that point is an
  out-of-memory error during initialization. However, another possible 
  reason for that is the --skip-grant-tables option in which case UDF 
  initialization is skipped and UDFs are unavailable.
  
  The solution is to check whether mysqld is running with
  --skip-grant-tables and issue a proper error in such a case.
[16 Nov 2007 9:30] Bugs System
Pushed into 5.0.52
[16 Nov 2007 9:33] Bugs System
Pushed into 5.1.23-rc
[16 Nov 2007 9:35] Bugs System
Pushed into 6.0.4-alpha
[28 Nov 2007 23:55] Paul Dubois
Noted in 5.0.52, 5.1.23, 6.0.4 changelogs.

User-defined functions are not loaded if the server is started with
the --skip-grant-tables option, but the server was not properly
handing this case and was issuing an out-of-memory error message
instead.
[11 Jan 2008 12:18] Bugs System
Pushed into 6.0.5-alpha
[11 Jan 2008 12:21] Bugs System
Pushed into 5.1.23-rc
[11 Jan 2008 12:22] Bugs System
Pushed into 5.0.56