Bug #45882 dtoa.c might not work with gcc 4.4.0
Submitted: 1 Jul 2009 14:54 Modified: 7 Jul 2010 18:52
Reporter: Paul DuBois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:azalea OS:Any
Assigned to: Alexey Kopytov CPU Architecture:Any

[1 Jul 2009 14:54] Paul DuBois
Description:
Per this article, gcc 4.4.0 has problems compiling dtoa.c correctly:

http://patrakov.blogspot.com/2009/03/dont-use-old-dtoac.html

We use that file (strings/dtoa.c), so we might be affected for builds that use gcc 4.4.0.

How to repeat:
See above.
[1 Jul 2009 15:31] MySQL Verification Team
Thank you for the bug report.
[2 Jul 2009 18:16] Sergei Golubchik
as a way to verify it we can try to compile with gcc 4.4.0 and run the test suite. If it'll work, perhaps SELECT "1.1"+0 (or something) will fail
[2 Jul 2009 21:46] MySQL Verification Team
The test suite fails:

main.locktrans_myisam                    [ pass ]    439
main.mysql_client_test                   [ fail ]
        Test ended at 2009-07-02 15:03:05

CURRENT_TEST: main.mysql_client_test
mysqltest: At line 14: command "$MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1" failed

Output from before failure:
exec of '/home/miguel/dbs/azalea/bin/mysql_client_test --defaults-file=/home/miguel/dbs/azalea/mysql-test/var/my.cnf --testcase --vardir=/home/miguel/dbs/azalea/mysql-test/var --getopt-ll-test=25600M >> /home/miguel/dbs/azalea/mysql-test/var/log/mysql_client_test.out.log 2>&1' failed, error: 256, status: 1, errno: 0

The result from queries just before the failure was:
SET @old_general_log= @@global.general_log;

 - saving '/home/miguel/dbs/azalea/mysql-test/var/log/main.mysql_client_test/' to '/home/miguel/dbs/azalea/mysql-test/var/log/main.mysql_client_test/'

Only  459  of 1564 completed.
mysql-test-run: *** ERROR: Not all tests completed

however the other test suggested by Serg no:

[miguel@hegel azalea]$ bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.4.4-alpha-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SELECT "1.1"+0;
+---------+
| "1.1"+0 |
+---------+
|     1.1 |
+---------+
1 row in set (0.00 sec)

mysql> exit
Bye
[miguel@hegel azalea]$ gcc --version
gcc (GCC) 4.4.0 20090506 (Red Hat 4.4.0-4)
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[miguel@hegel azalea]$

Please let me know if needed more test. Thanks
[2 Aug 2009 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[26 May 2010 14:35] Tor Didriksen
This unit test does *not* fail in optimized build for me:
#include <gtest/gtest.h>

#include <m_string.h>

TEST(Dtoa_test, convert)
{
  char char_buf[] = "1.1";
  double d= my_atof(char_buf);
  char flt_buff[FLOATING_POINT_BUFFER];
  my_bool error= FALSE;
  size_t ret= my_fcvt(d, 1, flt_buff, &error);
  EXPECT_EQ(strlen(char_buf), ret) << flt_buff;
  EXPECT_EQ(0, strcmp(char_buf, flt_buff)) << flt_buff;
} 

But I do get lots of warnings like:
warning: dereferencing pointer ‘a.73’ does break strict-aliasing rules

We should download, and integrate
http://www.netlib.org/fp/dtoa.c
[1 Jun 2010 12:25] Jon Olav Hauglid
I get test failures that seem related to this bug.
I'm using next-mr-bugfixing, release build (Ver 5.6.99-m4 for Linux on x86_64) on Ubuntu 10.04 x86_64 (2.6.32-22).

Tests that fail include type_float.test, type_decimal.test, insert.test, loaddata.test and func_math.test. They all fail by hanging until they timeout.

Stacktrace for hanging type_float.test:
#0  lshift (b=0x7ffff29de580, k=3069, alloc=0x7ffff29de360)
    at /export/home/x/mysql-next-mr-bugfixing-test/strings/dtoa.c:1058
#1  0x00000000007ead75 in my_strtod_int (str=<value optimized out>, 
    end=<value optimized out>, error=<value optimized out>)
    at /export/home/x/mysql-next-mr-bugfixing-test/strings/dtoa.c:1740
#2  my_strtod (str=<value optimized out>, end=<value optimized out>, 
    error=<value optimized out>)
    at /export/home/x/mysql-next-mr-bugfixing-test/strings/dtoa.c:469
#3  0x0000000000668660 in Item_float (this=0xf37c98, str_arg=0xf37c90 "1e-50", 
    length=5) at /export/home/x/mysql-next-mr-bugfixing-test/sql/item.cc:5574
#4  0x0000000000628e13 in MYSQLparse (yythd=0xe7a530)
    at /export/home/x/mysql-next-mr-bugfixing-test/sql/sql_yacc.yy:11739

I also get this test failure in cast.test:
 SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1;
 double_val	cast_val
--1e30	-9223372036854775808
-1e30	9223372036854775807
-Warnings:
-Warning	1292	Truncated incorrect INTEGER value: '-1e30'
-Warning	1292	Truncated incorrect INTEGER value: '1e30'
+-1e16	-10000000000000000
+1e16	10000000000000000
[1 Jun 2010 17:38] 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/commits/109798

3087 Alexey Kopytov	2010-06-01
      Bug #45882: dtoa.c might not work with gcc 4.4.0
      
      - Ported relevant changes from the upstream version to not
      break strict-aliasing rules and to fix compiler warnings and
      and infinite loops caused by that issue.
      
      - Fixed compilation with Honor_FLT_ROUNDS defined.
      
      - Fixed an unused variable warning.
[15 Jun 2010 8:08] Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100615080459-smuswd9ooeywcxuc) (version source revid:marko.makela@oracle.com-20100601134335-ccthwwru23kn09qw) (merge vers: 5.1.48) (pib:16)
[15 Jun 2010 8:24] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100615080558-cw01bzdqr1bdmmec) (version source revid:alik@sun.com-20100615080431-gu5icn0anrt47dsx) (pib:16)
[7 Jul 2010 18:52] Paul DuBois
Noted in 5.5.5 changelog.

gcc 4.4.0 could fail to compile dtoa.c.