List:Commits« Previous MessageNext Message »
From:kgeorge Date:June 22 2007 2:34pm
Subject:bk commit into 5.0 tree (gkodinov:1.2494) BUG#27383
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kgeorge. When kgeorge 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-06-22 15:34:28+03:00, gkodinov@stripped +1 -0
  Bug #27383: Crash in test "mysql_client_test"
  
  The C optimizer may decide that data access operations
  through pointer of different type are not related to 
  the original data (strict aliasing).
  This is what happens in fetch_long_with_conversion(),
  when called as part of mysql_stmt_fetch() : it tries 
  to check for truncation errors by first storing float
  (and other types of data) into a char * buffer and then 
  accesses them through a float pointer.
  This is done to prevent the effects of excess precision
  when using FPU registers.
  However the doublestore() macro converts a double pointer
  to an union pointer. This violates the strict aliasing rule.
  Fixed by making the intermediary variables volatile (
  to not re-introduce the excess precision bug) and using
  the intermediary value instead of the char * buffer.
  Note that there can be loss of precision for both signed
  and unsigned 64 bit integers converted to double and back,
  so the check must stay there (even for compatibility 
  reasons).
  Based on the excellent analysis in bug 28400.

  libmysql/libmysql.c@stripped, 2007-06-22 15:34:27+03:00, gkodinov@stripped +16 -11
    Bug #27383: avoid pointer aliasing problems while 
    not re-violating the Intel FPU gcc bug.

# 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:	gkodinov
# Host:	magare.gmz
# Root:	/home/kgeorge/mysql/work/B28400-5.0-opt

--- 1.256/libmysql/libmysql.c	2007-05-24 21:51:35 +03:00
+++ 1.257/libmysql/libmysql.c	2007-06-22 15:34:27 +03:00
@@ -3663,33 +3663,38 @@ static void fetch_long_with_conversion(M
   case MYSQL_TYPE_FLOAT:
   {
     /*
-      We need to store data in the buffer before the truncation check to
+      We need to mark the local variable volatile to
       workaround Intel FPU executive precision feature.
       (See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323 for details)
-      AFAIU it does not guarantee to work.
     */
-    float data;
+    volatile float data;
     if (is_unsigned)
+    {
       data= (float) ulonglong2double(value);
+      *param->error= ((ulonglong) value) != ((ulonglong) data);
+    }
     else
-      data= (float) value;
+    {
+      data= (float)value;
+      *param->error= value != ((longlong) data);
+    }
     floatstore(buffer, data);
-    *param->error= is_unsigned ?
-                   ((ulonglong) value) != ((ulonglong) (*(float*) buffer)) :
-                   ((longlong) value) != ((longlong) (*(float*) buffer));
     break;
   }
   case MYSQL_TYPE_DOUBLE:
   {
-    double data;
+    volatile double data;
     if (is_unsigned)
+    {
       data= ulonglong2double(value);
+      *param->error= ((ulonglong) value) != ((ulonglong) data);
+    }
     else
+    {
       data= (double)value;
+      *param->error= value != ((longlong) data);
+    }
     doublestore(buffer, data);
-    *param->error= is_unsigned ?
-                   ((ulonglong) value) != ((ulonglong) (*(double*) buffer)) :
-                   ((longlong) value) != ((longlong) (*(double*) buffer));
     break;
   }
   case MYSQL_TYPE_TIME:
Thread
bk commit into 5.0 tree (gkodinov:1.2494) BUG#27383kgeorge22 Jun
Re: bk commit into 5.0 tree (gkodinov:1.2494) BUG#27383Sergei Golubchik22 Jun