Bug #11247 Stored procedures: Function calls in long loops leak memory

Submitted: 10 Jun 2005 15:14 Modified: 18 Aug 2005 21:01
Reporter: Per-Erik Martin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0 OS:Any (Any)
Assigned to: Petr Chardin CPU Architecture:Any

[10 Jun 2005 15:14] Per-Erik Martin
Description:
(This is a continuation of BUG#10968.)

When running nested loops with function invokations, the server is leaking memory
and eventually starts thrashing.

With the included test case, it takes about 6 minutes (on an old 1.3GHz machine),
or when the outer loop count passes about 3500.

How to repeat:
drop function if exists pt7;
drop function if exists pt8;
drop procedure if exists pt9;

delimiter //;

create function pt7(param1 int)
  returns int
return param1 + 1//

create function pt8(param1 int)
  returns int
begin
  declare v int default 0;

  while v < param1 do
    set v = pt7(v);
  end while;
  return v;
end//

create procedure pt9(lim int)
begin
  declare v int default 0;

  while v < lim do
    select pt8(v);
    set v = v + 1;
  end while;
end//

delimiter ;//

call pt9(10000);
[14 Jun 2005 2:14] Peter Gulutzan
I experience trouble with a built-in function too, and after an hour or two it crashes.
5.0.8-beta-debug

set sql_mode='traditional'//

create procedure pv4 () begin declare v1 int default 0; while v1 < 1000000 do set v1 = v1 + 1; select v1, repeat('*',0); end while; end//

call pv4()//
[16 Aug 2005 19:15] 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/internals/28348
[18 Aug 2005 19:54] Petr Chardin
The fix will go into 5.0.12
[18 Aug 2005 21:01] Mike Hillyer
Documented in 5.0.12 changelog:

<listitem><para>Stored procedures with particularly long loops could crash server due to memory leak. (Bug #12297, Bug #11247)</para></listitem>

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.041 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.