[CONC-512] truncation check for float values fails on i386 due to Intel FPU optimization bug in gcc Created: 2020-10-29  Updated: 2020-11-08  Resolved: 2020-10-30

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: 3.1.10
Fix Version/s: 3.1.11

Type: Bug Priority: Blocker
Reporter: Marko Mäkelä Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to CONC-483 Workaround for MSAN bug needed Closed

 Description   

The 3 tests that would fail with MSAN (as mentioned in CONC-483) fail also when I build a 32-bit server and run non-MSAN tests locally. This happens on MariaDB Server 10.2, 10.3, 10.4 alike. Here is some sample output from a 10.4-based branch:

10.4 with libmariadb 0cdc1656a70c52103b4329debf9ed02ccacfb3c2

main.mysql_client_test                   w31 [ fail ]
        Test ended at 2020-10-29 10:01:52
 
CURRENT_TEST: main.mysql_client_test
mysqltest: At line 29: exec of '/dev/shm/10.4/tests/mysql_client_test --defaults-file=/dev/shm/10.4/mysql-test/var/31/my.cnf --testcase --vardir=/dev/shm/10.4/mysql-test/var/31 --getopt-ll-test=25600M >> /dev/shm/10.4/mysql-test/var/31/log/mysql_client_test.out.log 2>&1' failed, error: 256, status: 1, errno: 11
Output from before failure:
call mtr.add_suppression(" IP address .* could not be resolved");
 
 
 
The result from queries just before the failure was:
SET @save_character_set_client=    @@global.character_set_client;
SET @save_collation_connection=    @@global.collation_connection;
SET @@global.character_set_server= @@character_set_server;
SET @@global.collation_server=     @@collation_server;
SET @@global.character_set_client= @@character_set_server;
SET @@global.collation_connection= @@collation_server;
SET @old_general_log= @@global.general_log;
SET @old_slow_query_log= @@global.slow_query_log;
call mtr.add_suppression(" Error reading file './client_test_db/test_frm_bug.frm'");
call mtr.add_suppression(" IP address .* could not be resolved");
 
 - saving '/dev/shm/10.4/mysql-test/var/31/log/main.mysql_client_test/' to '/dev/shm/10.4/mysql-test/var/log/main.mysql_client_test/'
versioning.replace 'innodb,traditional,unique' w42 [ pass ]     14
***Warnings generated in error logs during shutdown after running tests: main.mysql_client_test
 
2020-10-29 10:01:50 0 [Warning] Plugin 'test_plugin_server' is of maturity level unknown while the server is stable
2020-10-29 10:01:50 0 [Warning] Plugin 'cleartext_plugin_server' is of maturity level unknown while the server is stable
main.mysql_client_test_nonblock          w16 [ fail ]
        Test ended at 2020-10-29 10:01:53
 
CURRENT_TEST: main.mysql_client_test_nonblock
mysqltest: At line 22: exec of '/dev/shm/10.4/tests/mysql_client_test --defaults-file=/dev/shm/10.4/mysql-test/var/16/my.cnf --testcase --vardir=/dev/shm/10.4/mysql-test/var/16 --non-blocking-api --getopt-ll-test=25600M >> /dev/shm/10.4/mysql-test/var/16/log/mysql_client_test.out.log 2>&1' failed, error: 256, status: 1, errno: 11
Output from before failure:
call mtr.add_suppression(" IP address .* could not be resolved");
 
 
 
The result from queries just before the failure was:
SET @old_general_log= @@global.general_log;
SET @old_slow_query_log= @@global.slow_query_log;
call mtr.add_suppression(" Error reading file './client_test_db/test_frm_bug.frm'");
call mtr.add_suppression(" IP address .* could not be resolved");
 
 - saving '/dev/shm/10.4/mysql-test/var/16/log/main.mysql_client_test_nonblock/' to '/dev/shm/10.4/mysql-test/var/log/main.mysql_client_test_nonblock/'
main.mysql_client_test_comp              w7 [ fail ]
        Test ended at 2020-10-29 10:03:35
 
CURRENT_TEST: main.mysql_client_test_comp
mysqltest: At line 14: exec of '/dev/shm/10.4/tests/mysql_client_test --defaults-file=/dev/shm/10.4/mysql-test/var/7/my.cnf --testcase --vardir=/dev/shm/10.4/mysql-test/var/7 --getopt-ll-test=25600M >> /dev/shm/10.4/mysql-test/var/7/log/mysql_client_test_comp.out.log 2>&1' failed, error: 256, status: 1, errno: 11
Output from before failure:
call mtr.add_suppression(" IP address .* could not be resolved");
 
 
 
The result from queries just before the failure was:
SET @old_slow_query_log= @@global.slow_query_log;
call mtr.add_suppression(" Error reading file './client_test_db/test_frm_bug.frm'");
call mtr.add_suppression(" IP address .* could not be resolved");
 
 - saving '/dev/shm/10.4/mysql-test/var/7/log/main.mysql_client_test_comp/' to '/dev/shm/10.4/mysql-test/var/log/main.mysql_client_test_comp/'
***Warnings generated in error logs during shutdown after running tests: main.mysql_client_test_comp
 
2020-10-29 10:03:32 0 [Warning] Plugin 'test_plugin_server' is of maturity level unknown while the server is stable
2020-10-29 10:03:32 0 [Warning] Plugin 'cleartext_plugin_server' is of maturity level unknown while the server is stable

I am configuring the build with the following script:

#!/bin/bash
set -ex
test ! -e .git
exec cmake -DWITH_EMBEDDED_SERVER=OFF -DWITH_SAFEMALLOC=OFF -DWITH_UNIT_TESTS=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_{C,CXX}_FLAGS='-O2 -m32 -march=i686' -DWITH_WSREP=OFF -DWITH_DBUG_TRACE=OFF -DPLUGIN_{ARCHIVE,TOKUDB,MROONGA,OQGRAPH,ROCKSDB,CONNECT}=NO -DWITH_SSL=bundled -DWITH_ZLIB=system -DCURSES_CURSES_H_PATH=/usr/include/curses.h -DCURSES_CURSES_LIBRARY=/usr/lib32/libcurses.a -DCURSES_FORM_LIBRARY=/usr/lib32/libform.so -DGNUTLS_LIBRARY=/usr/lib/i386-linux-gnu/libgnutls.so -DCMAKE_LIBRARY_ARCHITECTURE=lib32 "$@"
# sudo apt install g++-10-multilib lib32ncurses5-dev

The script has worked for me on Debian ever since GCC 6. My current GCC version is 10.2.0.

Note: the tests fail not only on 10.4 (where WITH_SSL=bundled is WolfSSL v4.4.0-stable at the moment), but also on 10.2 and 10.3.



 Comments   
Comment by Georg Richter [ 2020-10-30 ]

This behaviour is caused by bug gcc #323.
The suggested workaround is either to declare the float variable as volatile (to make sure it will be reread from memory), to use -ffloat-store option or to remove optimization for parts of code.

Comment by Georg Richter [ 2020-10-30 ]

fixed - rev. 93618b4036d61a4425154c7d8bc41647872b64cd

Generated at Thu Feb 08 03:05:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.