List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:March 1 2007 10:55am
Subject:bk commit into 5.0 tree (kaa:1.2404) BUG#5731
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kaa. When kaa does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-03-01 13:55:11+03:00, kaa@stripped +7 -0
  Fix for bug #5731 "key_buffer_size not properly restricted to 4GB".
  
  Problem: all memory allocation functions had an unsigned int argument specifying size of a block to allocate, which resulted in overflows when allocating buffers > 4GB on 64-bit systems.
  
  Solution: use size_t instead of uint to specify a memory block size. This is a minimal patch for 5.0 required to allow key_buffer_size > 4 GB on 64-bit systems. More cleanup work will be done in 5.1.

  include/my_sys.h@stripped, 2007-03-01 13:55:05+03:00, kaa@stripped +10 -10
    Changed the type of size arguments from uint to size_t in all memory allocation/manupilation functions.

  mysys/my_largepage.c@stripped, 2007-03-01 13:55:05+03:00, kaa@stripped +8 -6
    Changed the type of size arguments from uint to size_t in all memory allocation/manupilation functions.
    Use llstr() to print size_t values in non-DBUG prints.

  mysys/my_lockmem.c@stripped, 2007-03-01 13:55:05+03:00, kaa@stripped +2 -2
    Changed the type of size arguments from uint to size_t in all memory allocation/manupilation functions.

  mysys/my_malloc.c@stripped, 2007-03-01 13:55:05+03:00, kaa@stripped +5 -5
    Changed the type of size arguments from uint to size_t in all memory allocation/manupilation functions.

  mysys/my_realloc.c@stripped, 2007-03-01 13:55:05+03:00, kaa@stripped +3 -3
    Changed the type of size arguments from uint to size_t in all memory allocation/manupilation functions.

  mysys/my_static.h@stripped, 2007-03-01 13:55:05+03:00, kaa@stripped +1 -1
    Changed the datasize member of st_irem to size_t.

  mysys/safemalloc.c@stripped, 2007-03-01 13:55:05+03:00, kaa@stripped +14 -12
    Changed the type of size arguments from uint to size_t in all memory allocation/manupilation functions.
    Use llstr() to print size_t values in non-DBUG prints.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	kaa
# Host:	polly.local
# Root:	/tmp/maint/bug5731/my50-bug5731

--- 1.192/include/my_sys.h	2007-03-01 13:55:18 +03:00
+++ 1.193/include/my_sys.h	2007-03-01 13:55:18 +03:00
@@ -150,13 +150,13 @@ extern ulonglong sf_malloc_mem_limit;
 #define TERMINATE(A) {}
 #define QUICK_SAFEMALLOC
 #define NORMAL_SAFEMALLOC
-extern gptr my_malloc(uint Size,myf MyFlags);
+extern gptr my_malloc(size_t Size,myf MyFlags);
 #define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG )
-extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags);
+extern gptr my_realloc(gptr oldpoint,size_t Size,myf MyFlags);
 extern void my_no_flags_free(gptr ptr);
-extern gptr my_memdup(const byte *from,uint length,myf MyFlags);
+extern gptr my_memdup(const byte *from,size_t length,myf MyFlags);
 extern char *my_strdup(const char *from,myf MyFlags);
-extern char *my_strdup_with_length(const char *from, uint length,
+extern char *my_strdup_with_length(const char *from, size_t length,
 				   myf MyFlags);
 /* we do use FG (as a no-op) in below so that a typo on FG is caught */
 #define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR))
@@ -168,7 +168,7 @@ extern char *my_strdup_with_length(const
 
 #ifdef HAVE_LARGE_PAGES
 extern uint my_get_large_page_size(void);
-extern gptr my_large_malloc(uint size, myf my_flags);
+extern gptr my_large_malloc(size_t size, myf my_flags);
 extern void my_large_free(gptr ptr, myf my_flags);
 #else
 #define my_get_large_page_size() (0)
@@ -591,18 +591,18 @@ extern uint my_fwrite(FILE *stream,const
 		      myf MyFlags);
 extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
 extern my_off_t my_ftell(FILE *stream,myf MyFlags);
-extern gptr _mymalloc(uint uSize,const char *sFile,
+extern gptr _mymalloc(size_t uSize,const char *sFile,
 		      uint uLine, myf MyFlag);
-extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile,
+extern gptr _myrealloc(gptr pPtr,size_t uSize,const char *sFile,
 		       uint uLine, myf MyFlag);
 extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...));
 extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag);
 extern int _sanity(const char *sFile,unsigned int uLine);
-extern gptr _my_memdup(const byte *from,uint length,
+extern gptr _my_memdup(const byte *from,size_t length,
 		       const char *sFile, uint uLine,myf MyFlag);
 extern my_string _my_strdup(const char *from, const char *sFile, uint uLine,
 			    myf MyFlag);
-extern char *_my_strdup_with_length(const char *from, uint length,
+extern char *_my_strdup_with_length(const char *from, size_t length,
 				    const char *sFile, uint uLine,
 				    myf MyFlag);
 
@@ -786,7 +786,7 @@ extern my_bool dynstr_set(DYNAMIC_STRING
 extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size);
 extern void dynstr_free(DYNAMIC_STRING *str);
 #ifdef HAVE_MLOCK
-extern byte *my_malloc_lock(uint length,myf flags);
+extern byte *my_malloc_lock(size_t length,myf flags);
 extern void my_free_lock(byte *ptr,myf flags);
 #else
 #define my_malloc_lock(A,B) my_malloc((A),(B))

--- 1.5/mysys/my_lockmem.c	2007-03-01 13:55:18 +03:00
+++ 1.6/mysys/my_lockmem.c	2007-03-01 13:55:18 +03:00
@@ -31,7 +31,7 @@ struct st_mem_list
 
 LIST *mem_list;
 
-byte *my_malloc_lock(uint size,myf MyFlags)
+byte *my_malloc_lock(size_t size,myf MyFlags)
 {
   int success;
   uint pagesize=sysconf(_SC_PAGESIZE);
@@ -39,7 +39,7 @@ byte *my_malloc_lock(uint size,myf MyFla
   struct st_mem_list *element;
   DBUG_ENTER("my_malloc_lock");
 
-  size=((size-1) & ~(pagesize-1))+pagesize;
+  size=((size-1) & ~((size_t)pagesize-1))+pagesize;
   if (!(ptr=memalign(pagesize,size)))
   {
     if (MyFlags & (MY_FAE+MY_WME))

--- 1.12/mysys/my_malloc.c	2007-03-01 13:55:18 +03:00
+++ 1.13/mysys/my_malloc.c	2007-03-01 13:55:18 +03:00
@@ -23,11 +23,11 @@
 
 	/* My memory allocator */
 
-gptr my_malloc(unsigned int size, myf my_flags)
+gptr my_malloc(size_t size, myf my_flags)
 {
   gptr point;
   DBUG_ENTER("my_malloc");
-  DBUG_PRINT("my",("size: %u  my_flags: %d",size, my_flags));
+  DBUG_PRINT("my",("size: %lu  my_flags: %d",(ulong)size, my_flags));
 
   if (!size)
     size=1;					/* Safety */
@@ -63,7 +63,7 @@ void my_no_flags_free(gptr ptr)
 
 	/* malloc and copy */
 
-gptr my_memdup(const byte *from, uint length, myf my_flags)
+gptr my_memdup(const byte *from, size_t length, myf my_flags)
 {
   gptr ptr;
   if ((ptr=my_malloc(length,my_flags)) != 0)
@@ -75,14 +75,14 @@ gptr my_memdup(const byte *from, uint le
 char *my_strdup(const char *from, myf my_flags)
 {
   gptr ptr;
-  uint length=(uint) strlen(from)+1;
+  size_t length=(size_t) strlen(from)+1;
   if ((ptr=my_malloc(length,my_flags)) != 0)
     memcpy((byte*) ptr, (byte*) from,(size_t) length);
   return((my_string) ptr);
 }
 
 
-char *my_strdup_with_length(const char *from, uint length, myf my_flags)
+char *my_strdup_with_length(const char *from, size_t length, myf my_flags)
 {
   gptr ptr;
   if ((ptr=my_malloc(length+1,my_flags)) != 0)

--- 1.10/mysys/my_realloc.c	2007-03-01 13:55:18 +03:00
+++ 1.11/mysys/my_realloc.c	2007-03-01 13:55:18 +03:00
@@ -22,12 +22,12 @@
 
 	/* My memory re allocator */
 
-gptr my_realloc(gptr oldpoint, uint size, myf my_flags)
+gptr my_realloc(gptr oldpoint, size_t size, myf my_flags)
 {
   gptr point;
   DBUG_ENTER("my_realloc");
-  DBUG_PRINT("my",("ptr: 0x%lx  size: %u  my_flags: %d", (long) oldpoint, size,
-		   my_flags));
+  DBUG_PRINT("my",("ptr: 0x%lx  size: %lu  my_flags: %d", (long) oldpoint,
+                   (ulong)size, my_flags));
 
   if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
     DBUG_RETURN(my_malloc(size,my_flags));

--- 1.19/mysys/my_static.h	2007-03-01 13:55:18 +03:00
+++ 1.20/mysys/my_static.h	2007-03-01 13:55:18 +03:00
@@ -45,7 +45,7 @@ struct st_irem
   struct st_irem *prev;		/* Other link			   */
   char *filename;		/* File in which memory was new'ed */
   uint32 linenum;		/* Line number in above file	   */
-  uint32 datasize;		/* Size requested		   */
+  size_t datasize;		/* Size requested		   */
   uint32 SpecialValue;		/* Underrun marker value	   */
 };
 

--- 1.27/mysys/safemalloc.c	2007-03-01 13:55:18 +03:00
+++ 1.28/mysys/safemalloc.c	2007-03-01 13:55:18 +03:00
@@ -119,12 +119,12 @@ static int _checkchunk(struct st_irem *p
 
 /* Allocate some memory. */
 
-gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags)
+gptr _mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags)
 {
   struct st_irem *irem;
   char *data;
   DBUG_ENTER("_mymalloc");
-  DBUG_PRINT("enter",("Size: %u",size));
+  DBUG_PRINT("enter",("Size: %lu",(ulong)size));
 
   if (!sf_malloc_quick)
     (void) _sanity (filename, lineno);
@@ -148,12 +148,14 @@ gptr _mymalloc(uint size, const char *fi
     if (MyFlags & (MY_FAE+MY_WME))
     {
       char buff[SC_MAXWIDTH];
+      char llbuf1[22], llbuf2[22], llbuf3[22], llbuf4[22];
       my_errno=errno;
       sprintf(buff,"Out of memory at line %d, '%s'", lineno, filename);
       my_message(EE_OUTOFMEMORY,buff,MYF(ME_BELL+ME_WAITTANG));
-      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);
+      sprintf(buff,"needed %s bytes (%sk), memory in use: %s bytes (%sk)",
+              llstr(size, llbuf1), llstr((size + 1023UL) / 1024UL, llbuf2),
+              llstr(sf_malloc_max_memory, llbuf3),
+              llstr((sf_malloc_max_memory + 1023UL) / 1024UL, llbuf4));
       my_message(EE_OUTOFMEMORY,buff,MYF(ME_BELL+ME_WAITTANG));
     }
     DBUG_PRINT("error",("Out of memory, in use: %ld at line %d, '%s'",
@@ -207,7 +209,7 @@ gptr _mymalloc(uint size, const char *fi
   Free then old memoryblock
 */
 
-gptr _myrealloc(register gptr ptr, register uint size,
+gptr _myrealloc(register gptr ptr, register size_t size,
 		const char *filename, uint lineno, myf MyFlags)
 {
   struct st_irem *irem;
@@ -402,14 +404,14 @@ void TERMINATE(FILE *file)
       if (file)
       {
 	fprintf(file,
-		"\t%6u bytes at 0x%09lx, allocated at line %4u in '%s'",
-		irem->datasize, (long) data, irem->linenum, irem->filename);
+		"\t%6lu bytes at 0x%09lx, allocated at line %4u in '%s'",
+		(ulong)irem->datasize, (long) data, irem->linenum, irem->filename);
 	fprintf(file, "\n");
 	(void) fflush(file);
       }
       DBUG_PRINT("safe",
-		 ("%6u bytes at 0x%09lx, allocated at line %4d in '%s'",
-		  irem->datasize, (long) data, irem->linenum, irem->filename));
+		 ("%6lu bytes at 0x%09lx, allocated at line %4d in '%s'",
+		  (ulong)irem->datasize, (long) data, irem->linenum, irem->filename));
       irem= irem->next;
     }
   }
@@ -503,7 +505,7 @@ int _sanity(const char *filename, uint l
 
 	/* malloc and copy */
 
-gptr _my_memdup(const byte *from, uint length, const char *filename,
+gptr _my_memdup(const byte *from, size_t length, const char *filename,
 		uint lineno, myf MyFlags)
 {
   gptr ptr;
@@ -524,7 +526,7 @@ char *_my_strdup(const char *from, const
 } /* _my_strdup */
 
 
-char *_my_strdup_with_length(const char *from, uint length,
+char *_my_strdup_with_length(const char *from, size_t length,
 			     const char *filename, uint lineno,
 			     myf MyFlags)
 {

--- 1.2/mysys/my_largepage.c	2007-03-01 13:55:18 +03:00
+++ 1.3/mysys/my_largepage.c	2007-03-01 13:55:18 +03:00
@@ -14,6 +14,7 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #include "mysys_priv.h"
+#include <m_string.h>
 
 #ifdef HAVE_LARGE_PAGES
 
@@ -26,7 +27,7 @@
 #endif
 
 static uint my_get_large_page_size_int(void);
-static gptr my_large_malloc_int(uint size, myf my_flags);
+static gptr my_large_malloc_int(size_t size, myf my_flags);
 static my_bool my_large_free_int(gptr ptr, myf my_flags);
 
 /* Gets the size of large pages from the OS */
@@ -48,7 +49,7 @@ uint my_get_large_page_size(void)
   my_malloc_lock() in case of failure
 */
 
-gptr my_large_malloc(uint size, myf my_flags)
+gptr my_large_malloc(size_t size, myf my_flags)
 {
   gptr ptr;
   DBUG_ENTER("my_large_malloc");
@@ -113,23 +114,24 @@ finish:
 #if HAVE_DECL_SHM_HUGETLB
 /* Linux-specific large pages allocator  */
     
-gptr my_large_malloc_int(uint size, myf my_flags)
+gptr my_large_malloc_int(size_t size, myf my_flags)
 {
   int shmid;
   gptr ptr;
   struct shmid_ds buf;
+  char llbuf[22];
   DBUG_ENTER("my_large_malloc_int");
 
   /* Align block size to my_large_page_size */
-  size = ((size - 1) & ~(my_large_page_size - 1)) + my_large_page_size;
+  size = ((size-1) & ~((size_t)my_large_page_size-1)) + my_large_page_size;
   
   shmid = shmget(IPC_PRIVATE, (size_t)size, SHM_HUGETLB | SHM_R | SHM_W);
   if (shmid < 0)
   {
     if (my_flags & MY_WME)
       fprintf(stderr,
-              "Warning: Failed to allocate %d bytes from HugeTLB memory."
-              " errno %d\n", size, errno);
+              "Warning: Failed to allocate %s bytes from HugeTLB memory."
+              " errno %d\n", llstr(size, llbuf), errno);
 
     DBUG_RETURN(NULL);
   }
Thread
bk commit into 5.0 tree (kaa:1.2404) BUG#5731Alexey Kopytov1 Mar