Bug #28400 | make test Failed mysql_client_test test_fetch_long | ||
---|---|---|---|
Submitted: | 13 May 2007 14:29 | Modified: | 23 Jun 2007 8:45 |
Reporter: | imacat . (Basic Quality Contributor) | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | MySQL Server: Tests | Severity: | S7 (Test Cases) |
Version: | 5.0.41 | OS: | Linux (2.6.18) |
Assigned to: | Georgi Kodinov | CPU Architecture: | Any |
Tags: | qc |
[13 May 2007 14:29]
imacat .
[14 May 2007 9:12]
Valeriy Kravchuk
Thank you for a problem report. Please, send the results of env from your testing environment. Please, also upload compressed .tar of var/log subdirectory of mysql-test directory after running this test.
[14 May 2007 9:42]
imacat .
master.log in the mysql-test/var/log Directory
Attachment: mysql-5.0.41_mysql-test_var_log-master.log.tar.bz2 (application/octet-stream, text), 460.77 KiB.
[14 May 2007 9:43]
imacat .
Files Other Than master.log in the mysql-test/var/log Directory
Attachment: mysql-5.0.41_mysql-test_var_log-rest.tar.bz2 (application/octet-stream, text), 43.57 KiB.
[14 May 2007 9:46]
imacat .
Hi. This is imacat from Taiwan. The mysql-test/var/log directory is uploaded. Here is the environment. Please tell me if you need any more information, or if I could be of any help. Thank you. imacat@gaya src/mysql-5.0.41 % env USER=imacat LOGNAME=imacat HOME=/home/imacat PATH=/home/imacat/bin:/bin:/usr/bin:/opt/java/bin:/usr/local/bin MAIL=/var/mail/imacat SHELL=/bin/zsh SSH_CLIENT=211.78.169.163 49745 22 SSH_CONNECTION=211.78.169.163 49745 211.78.163.131 22 SSH_TTY=/dev/pts/1 TERM=xterm SSH_AUTH_SOCK=/var/run/ssh/ssh-imNpAn4242/agent.4242 SHLVL=1 PWD=/usr/local/src/mysql-5.0.41 OLDPWD=/usr/local/src HISTFILE=/home/imacat/.bash_history SAVEHIST=1000 EDITOR=nano -w PERL5LIB=/home/imacat/lib/perl5 MAKEFLAGS=--quiet INFOPATH=/home/imacat/share/info:/home/imacat/info:/home/imacat/local/share/info:/home/imacat/local/info WWW_HOME=http://www.imacat.idv.tw/home/ CVSROOT=:ext:rinse.wov.idv.tw:/var/lib/cvsroot OPENSSL_CONF=/etc/ssl/openssl.cnf PGHOST=/var/run/postgres LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.flac=01;35:*.mp3=01;35:*.mpc=01;35:*.ogg=01;35:*.wav=01;35: _=/usr/bin/env imacat@gaya src/mysql-5.0.41 %
[24 May 2007 20:52]
Peter O'Gorman
We also see this test failure on Red Hat Enterprise Linux 5, gcc-4.1 mysql-5.0.38
[4 Jun 2007 19:09]
TOM DONOVAN
Also observed with MySQL 5.0.42 on Linux 2.6.18 with gcc 4.1.2. The error is that the call to mysql_stmt_fetch in tests/mysql_client_test.c:3892 returns MYSQL_DATA_TRUNCATED. The field my_bind[5] (MYSQL_TYPE_DOUBLE) is incorrectly reported as being truncated. This problem could affect any numeric field which is bound to a float or double parameter, although it is more likely to occur with doubles than floats because they occupy the fpu longer. The function fetch_long_with_conversion in libmysql/libmysql.c:3638 uses unsafe aliasing of doubles/floats vs. int64s. Although the code looks OK, on a fast cpu with optimized code the check for truncation can happen before the fp value is fully converted. A workaround is to build MySQL with no optimizations, or else add the gcc flag -fno-strict-aliasing. e.g.: CFLAGS="-O3 -DNDEBUG -fno-strict-aliasing" ./configure ...options... Some notes on unsafe aliasing which explain why the macro 'doublestore' and the (u)longlong casts in libmysql.c are evil: gcc common Bugs: http://gcc.gnu.org/bugs.html#nonbugs_c gcc Bug 21920 (Resolved - Invalid bug): http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21920 gcc "strict aliasing": http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Optimize-Options.html#index-fstrict_002daliasi...
[5 Jun 2007 18:27]
TOM DONOVAN
Looking more carefully, the truncation check for conversions to float or double are not necessary. MySQL 5.0.19 libmysql/libmysql.c lines 3673 & 3686 All possible 64-bit integer values convert to either float or double OK. Precision may be lost (expected and allowed), but either float or double can represent 64-bit numbers between -9223372036854775807 and +9223372036854775807. Only the least-significant digits are lost. SQL-92 section 4.6 "Type conversions and mixing of data types" says: Values of the data types NUMERIC, DECIMAL, INTEGER, SMALLINT, FLOAT, REAL, and DOUBLE PRECISION are numbers and are all mutually comparable and mutually assignable. If an assignment would result in a loss of the most-significant digits, an exception condition is raised. If least-significant digits are lost, implementation-defined rounding or truncating occurs with no exception condition being raised. These truncation checks should be removed from both the functions fetch_long_with_conversion and fetch_float_with_conversion so they never set the truncation error flag when converting numbers to float or double.
[5 Jun 2007 18:38]
TOM DONOVAN
Apologies. There is a typo in my last note. The source code lines (truncation check) that I meant to reference are: MySQL 5.1.19 libmysql/libmysql.c lines 3673 & 3686 MySQL 5.0.42 libmysql/libmysql.c lines 3679 & 3692
[15 Jun 2007 13:36]
Valeriy Kravchuk
Tom, Thank you for the detailed analysis. Verifed on both 5.0-BK and 5.1-BK with code review. Test failure is not repeatable when gcc 3.x.y is used for compilation.
[19 Jun 2007 15:58]
Georgi Kodinov
Looks like related to bug #27383
[20 Jun 2007 8:36]
Georgi Kodinov
Marking this bug as a duplicate to 27383.