Bug #119639 Assertion Failure in LEAST() Function with Unsigned Columns

Submitted: 7 Jan 9:05 Modified: 21 Jan 13:00
Reporter: Jason Tang Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S2 (Serious)
Version:8.0.42 OS:Any
Assigned to: CPU Architecture:Any

[7 Jan 9:05] Jason Tang
Description:
MySQL 8.0.42-debug crashes with a critical assertion failure (Assertion '!unsigned_flag || !arg_val.is_negative()' failed) when executing queries involving LEAST() with unsigned columns and negative values. This is a severe stability bug causing complete server crashes.

How to repeat:
DROP DATABASE IF EXISTS database12;
CREATE DATABASE database12;
USE database12;
SET GLOBAL host_cache_size = 65536;
SET GLOBAL tmp_table_size = 1024;
 CREATE TABLE `t2` (
  `c0` tinyint(107) unsigned zerofill DEFAULT NULL,
  UNIQUE KEY `i0` (`c0` DESC)
);
SELECT t2.c0 AS ref0 FROM t2 WHERE (NOT ((+ (((t2.c0) NOT IN (-952979894)) OR (LEAST(t2.c0, t2.c0))))));
No connection. Trying to reconnect...
Connection id:    8
Current database: database12

ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...

When executing the query statement, the database crashed.

mysqld: /home/tzx/mysql-server-mysql-8.0.42/sql/item_func.cc:3937: virtual longlong Item_func_min_max::int_op(): Assertion `!unsigned_flag || !arg_val.is_negative()' failed.
2026-01-07T08:58:33Z UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
BuildID[sha1]=74c66055f3de3ce92689b61f26f34703359b2316
Thread pointer: 0x7f9f64001050
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7fa0144f39b8 thread_stack 0x100000
/usr/local/mysql/bin/mysqld(my_print_stacktrace(unsigned char const*, unsigned long)+0x4c) [0x55e516b93edc]
/usr/local/mysql/bin/mysqld(print_fatal_signal(int)+0x398) [0x55e514a9d2e8]
/usr/local/mysql/bin/mysqld(handle_fatal_signal+0x69) [0x55e514a9d4c9]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7fa02bacf520]
/lib/x86_64-linux-gnu/libc.so.6(pthread_kill+0x12c) [0x7fa02bb239fc]
/lib/x86_64-linux-gnu/libc.so.6(raise+0x16) [0x7fa02bacf476]
/lib/x86_64-linux-gnu/libc.so.6(abort+0xd3) [0x7fa02bab57f3]
/lib/x86_64-linux-gnu/libc.so.6(+0x2871b) [0x7fa02bab571b]
/lib/x86_64-linux-gnu/libc.so.6(+0x39e96) [0x7fa02bac6e96]
/usr/local/mysql/bin/mysqld(Item_func_min_max::int_op()+0x584) [0x55e514e5cbc4]
/usr/local/mysql/bin/mysqld(Arg_comparator::compare_int_signed_unsigned()+0x121) [0x55e514da6371]
/usr/local/mysql/bin/mysqld(Item_func_eq::val_int()+0x85) [0x55e514dac1e5]
/usr/local/mysql/bin/mysqld(Item::val_bool()+0x86) [0x55e514d4a6a6]
/usr/local/mysql/bin/mysqld(eval_const_cond(THD*, Item*, bool*)+0x6e) [0x55e514e3ab2e]
/usr/local/mysql/bin/mysqld(remove_eq_conds(THD*, Item*, Item**, Item::cond_result*)+0x77d) [0x55e51472172d]
/usr/local/mysql/bin/mysqld(remove_eq_conds(THD*, Item*, Item**, Item::cond_result*)+0x254) [0x55e514721204]
/usr/local/mysql/bin/mysqld(optimize_cond(THD*, Item**, COND_EQUAL**, mem_root_deque<Table_ref*>*, Item::cond_result*)+0xb33) [0x55e514712553]
/usr/local/mysql/bin/mysqld(JOIN::optimize(bool)+0x1934) [0x55e51470dfd4]
/usr/local/mysql/bin/mysqld(Query_block::optimize(THD*, bool)+0x1cf) [0x55e51483d31f]
/usr/local/mysql/bin/mysqld(Query_expression::optimize(THD*, TABLE*, bool, bool)+0x162) [0x55e51493f5e2]
/usr/local/mysql/bin/mysqld(Sql_cmd_dml::execute_inner(THD*)+0x4c) [0x55e51483805c]
/usr/local/mysql/bin/mysqld(Sql_cmd_dml::execute(THD*)+0x99d) [0x55e51483699d]
/usr/local/mysql/bin/mysqld(mysql_execute_command(THD*, bool)+0x4e93) [0x55e5147678a3]
/usr/local/mysql/bin/mysqld(dispatch_sql_command(THD*, Parser_state*)+0xfa8) [0x55e51475f0d8]
/usr/local/mysql/bin/mysqld(dispatch_command(THD*, COM_DATA const*, enum_server_command)+0x4792) [0x55e514759d32]
/usr/local/mysql/bin/mysqld(do_command(THD*)+0x9de) [0x55e51475ca8e]
/usr/local/mysql/bin/mysqld(+0x170b554) [0x55e514a78554]
/usr/local/mysql/bin/mysqld(+0x48e64dc) [0x55e517c534dc]
/lib/x86_64-linux-gnu/libc.so.6(+0x94ac3) [0x7fa02bb21ac3]
[7 Jan 10:21] Roy Lyseng
Thank you for the bug report.
Verified as described in debug builds.
[21 Jan 13:00] Knut Anders Hatlen
Seems to be the same problem as bug#119606. Closing as duplicate.
[21 Jan 21:05] Jean-François Gagné
Bug#119606 was fixed in 9.2, but it still affects 8.4.8 and 8.0.45.

I added a comment about this in Bug#119606.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.041 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.