List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:April 27 2008 10:00am
Subject:bk commit into 6.0 tree (kaa:1.2626) BUG#36320 WL#2934
View as plain text  
Below is the list of changes that have just been committed into a local
6.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, 2008-04-27 12:00:14+04:00, kaa@stripped +1 -0
  Fix for bug #36320: server crashes on "select 1e37" and on "select 
                      -1e15" etc.
  
  The bug is a regression introduced by the patch for WL #2934.
  
  On 64-bit architectures with strict alignment rules converting some 
  floating point numbers to/from strings could crash the server due to
  improper alignment of internal data structures.
  
  Fixed allocation routines in dtoa.c to ensure allocated objects to be
  aligned by the pointer size.
  
  No test case is required because the necessary coverage is provided
  by existing tests.

  strings/dtoa.c@stripped, 2008-04-27 12:00:11+04:00, kaa@stripped +7 -4
    Fixed allocators to ensure allocated objects to be aligned by the
    pointer size.

diff -Nrup a/strings/dtoa.c b/strings/dtoa.c
--- a/strings/dtoa.c	2008-01-08 10:33:02 +03:00
+++ b/strings/dtoa.c	2008-04-27 12:00:11 +04:00
@@ -648,7 +648,9 @@ typedef struct Stack_alloc
 
 /*
   Try to allocate object on stack, and resort to malloc if all
-  stack memory is used.
+  stack memory is used. Ensure allocated objects to be aligned by the pointer
+  size in order to not break the alignment rules when storing a pointer to a
+  Bigint.
 */
 
 static Bigint *Balloc(int k, Stack_alloc *alloc)
@@ -664,7 +666,7 @@ static Bigint *Balloc(int k, Stack_alloc
     int x, len;
 
     x= 1 << k;
-    len= sizeof(Bigint) + x * sizeof(ULong);
+    len= MY_ALIGN(sizeof(Bigint) + x * sizeof(ULong), SIZEOF_CHARP);
 
     if (alloc->free + len <= alloc->end)
     {
@@ -709,13 +711,14 @@ static void Bfree(Bigint *v, Stack_alloc
 /*
   This is to place return value of dtoa in: tries to use stack
   as well, but passes by free lists management and just aligns len by
-  sizeof(ULong).
+  the pointer size in order to not break the alignment rules when storing a
+  pointer to a Bigint.
 */
 
 static char *dtoa_alloc(int i, Stack_alloc *alloc)
 {
   char *rv;
-  int aligned_size= (i + sizeof(ULong) - 1) / sizeof(ULong) * sizeof(ULong);
+  int aligned_size= MY_ALIGN(i, SIZEOF_CHARP);
   if (alloc->free + aligned_size <= alloc->end)
   {
     rv= alloc->free;
Thread
bk commit into 6.0 tree (kaa:1.2626) BUG#36320 WL#2934Alexey Kopytov27 Apr 2008