Bug #29159 use unsigned values when reporting memory errors
Submitted: 17 Jun 2007 10:40 Modified: 25 Sep 2009 11:50
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Errors Severity:S3 (Non-critical)
Version:5.x OS:Any
Assigned to: Lars-Erik Bjørk CPU Architecture:Any

[17 Jun 2007 10:40] Shane Bester
Description:
when reporting errors about amounts of memory, the numbers should be unsigned.

This error is useless:

70617  9:40:05 [ERROR] mysqld-debug: Out of memory at line 201, '.\my_alloc.c'
070617  9:40:05 [ERROR] mysqld-debug: needed -1218034160 byte (3004818k), memory in use:
9735342 bytes (9508k)

How to repeat:
look at source code of _mymalloc in safemalloc.c 

if (MyFlags & (MY_FAE+MY_WME))
{
     char buff[SC_MAXWIDTH];
     my_errno=errno;
     sprintf(buff,"Out of memory at line %d, '%s'", lineno, filename);
     my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH));
     sprintf(buff,"needed %d byte (%ldk), memory in use: %ld bytes (%ldk)",
      size, (size + 1023L) / 1024L,
      sf_malloc_max_memory, (sf_malloc_max_memory + 1023L) / 1024L);
     my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH));
}

Suggested fix:
use %lu instead of %d ?
[17 Sep 2009 14:49] Konstantin Osipov
Lars-Erik, please implement the suggestion from Shane.
[25 Sep 2009 11:50] Lars-Erik Bjørk
Already fixed by patch for Bug#35616: memory overrun on 64-bit linux on setting large values for keybuffer-size