[MDEV-20966] main.func_math fails in builbot on Debian unstable with wrong error code Created: 2019-11-03  Updated: 2023-05-19

Status: Stalled
Project: MariaDB Server
Component/s: Server, Tests
Affects Version/s: 10.2, 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: Papercut, UBSAN, not-10.5

Issue Links:
Relates
relates to MDBF-536 Remove Fedora 36 builder reporting to... Closed
relates to MDEV-21977 main.func_math fails due to undefined... Closed
relates to MDEV-26645 test main.func_math fails on MariaDB ... Closed

 Description   

http://buildbot.askmonty.org/buildbot/builders/kvm-deb-sid-x86/builds/9229

10.4 903f5fea30cb236c5980a07b7fa63450

main.func_math                           w4 [ fail ]
        Test ended at 2019-11-02 15:51:08
 
CURRENT_TEST: main.func_math
mysqltest: At line 329: query 'SELECT -9223372036854775808 DIV -1' succeeded - should have failed with errno 1690...
 
The result from queries just before the failure was:
< snip >
CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a;
SELECT RAND(a) FROM v1;
RAND(a)
0.15522042769493574
DROP VIEW v1;
SELECT RAND(a) FROM (SELECT NULL AS a) b;
RAND(a)
0.15522042769493574
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (NULL);
SELECT RAND(i) FROM t1;
RAND(i)
0.15522042769493574
DROP TABLE t1;
#
# Bug#57477 SIGFPE when dividing a huge number a negative number
#
SELECT -9999999999999999991 DIV -1;
ERROR 22003: BIGINT value is out of range in '-9999999999999999991 DIV -1'
SELECT -9223372036854775808 DIV -1;
 
More results from queries before failure can be found in /dev/shm/var/4/log/func_math.log
 
Warnings from just before the error:
Warning 1916 Got overflow when converting '9999999999999999991' to INT. Value truncated



 Comments   
Comment by Daniel Black [ 2021-07-07 ]

func_math passing on this recent build http://buildbot.askmonty.org/buildbot/builders/kvm-deb-sid-x86/builds/12362/steps/mtr/logs/stdio ( 10.5)
http://buildbot.askmonty.org/buildbot/builders/kvm-deb-sid-x86/builds/12360/steps/mtr/logs/stdio (10.6)

Can't find recent 10.4 test on deb-sid-x86

Comment by Marko Mäkelä [ 2022-03-29 ]

The test main.func_math fails due to undefined behaviour on 10.2, 10.3, 10.4 when built with gcc-12 -O2 for AMD64, or even some older GCC on non-AMD64 instruction set architectures, such as POWER or IBM Z Series (s390x).

For 10.5 and later, MDEV-26645 fixed this by removing an ‘optimization’. Here is a recent example:

CURRENT_TEST: main.func_math
mysqltest: At line 425: query 'SELECT 9223372036854775807 + 9223372036854775807' succeeded - should have failed with errno 1690...

The reason for this failure is that the compiler is allowed to assume that no undefined behaviour exists. Specifically, if the compiler was asked to evaluate a+b, and the code subsequently checks for overflow, the compiler is allowed to assume that no overflow occurred in the first place, and to optimize away the overflow check.

Comment by Andrew Hutchings [ 2023-02-08 ]

This affects the Fedora 36 builder on new buildbot for 10.3 & 10.4.

Comment by Daniel Black [ 2023-02-09 ]

Attempted to backport the UB fixed and failed https://github.com/MariaDB/server/pull/2458.

As Fedora 36 comes with 10.5 and and with luck and a lot of hard work, Debian 12 will come with 10.11 I think the set distros with new compilers needing this fixed for 10.3/10.4 has been reduce to an empty set..

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