Bug #24657 debug assertation fails (string store)

Submitted: 28 Nov 2006 15:12 Modified: 10 Jan 2008 9:49
Reporter: Martin Friebe (Gold Quality Contributor) (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:4.1.22, 5.0.27/4.1BK/5.0BK/5.1BK OS:FreeBSD (freebsd/Suse Linux 10)
Assigned to: Assigned Account CPU Architecture:Any
Tags: assert, debug, qc

[28 Nov 2006 15:12] Martin Friebe
Description:
mysql compiled from the source tarball with the --debug option will fail an assertation on the belo testcase.

how to repeat, contains the content for mysql-test/t/insert.test

the r.insert.result file can be empty or anything

the server will fail an assertation with this test

stacktrace for mysql 4:
(see line 13 / 14 : at field.cc:5028)

#0  0x2841c31b in pthread_testcancel () from /usr/lib/libpthread.so.1
#1  0x284071dd in pthread_kill () from /usr/lib/libpthread.so.1
#2  0x0817245e in write_core (sig=6) at stacktrace.c:245
#3  0x080ac3e7 in handle_segfault (sig=6) at mysqld.cc:2022
#4  0x2840be26 in sigaction () from /usr/lib/libpthread.so.1
#5  0x2840bcab in sigaction () from /usr/lib/libpthread.so.1
#6  0x2840c86c in sigaction () from /usr/lib/libpthread.so.1
#7  0x2840cafe in sigaction () from /usr/lib/libpthread.so.1
#8  0x28414043 in pthread_mutexattr_init () from /usr/lib/libpthread.so.1
#9  0x2841ca35 in pthread_testcancel () from /usr/lib/libpthread.so.1
#10 0x284071ee in pthread_kill () from /usr/lib/libpthread.so.1
#11 0x28406bac in raise () from /usr/lib/libpthread.so.1
#12 0x285c4c1b in abort () from /lib/libc.so.5
#13 0x2859f9ff in __assert () from /lib/libc.so.5
#14 0x0809773c in Field_str::store (this=0xa3bf558, nr=0.98696366696335713) at field.cc:5028
#15 0x0809be08 in Field_string::store (this=0xa3bf558, nr=0.98696366696335713) at field.h:911
#16 0x0814a5a1 in field_conv (to=0xa3bf558, from=0xa3c5038) at field_conv.cc:634
#17 0x080547e4 in Item_field::save_in_field (this=0xa3c5150, to=0xa3bf558, no_conversions=false) at item.cc:2115
#18 0x080df15c in fill_record (ptr=0xa3bf53c, values=@0xa3c4bb0, ignore_errors=true) at sql_base.cc:2936
#19 0x080fe041 in select_insert::store_values (this=0xa051e00, values=@0xa051e00) at sql_insert.cc:1700
#20 0x080fdf3d in select_insert::send_data (this=0xa3c4208, values=@0xa3c4bb0) at sql_insert.cc:1671
#21 0x080f24bf in end_send (join=0xa3c4258, join_tab=0xa3c5304, end_of_records=false) at sql_select.cc:6802
#22 0x080f13c4 in sub_select (join=0xa3c4258, join_tab=0xa3c51c0, end_of_records=false) at sql_select.cc:6221
#23 0x080f0fa6 in do_select (join=0xa3c4258, fields=0xa3c4bb0, table=0x0, procedure=0x80f23f8) at sql_select.cc:6105
#24 0x080e6688 in JOIN::exec (this=0xa3c4258) at sql_select.cc:1592
#25 0x080e6b85 in mysql_select (thd=0xa3ad000, rref_pointer_array=0xa3ad218, tables=0xa3c41a0, wild_num=0, fields=@0xa3ad194, conds=0x0, og_num=0, order=0x0,
    group=0x0, having=0x0, proc_param=0x0, select_options=2458274304, result=0xa3c4208, unit=0xa3ad048, select_lex=0xa3ad128) at sql_select.cc:1716
#26 0x080e2dd5 in handle_select (thd=0xa3ad000, lex=0xa3ad03c, result=0xa3c4208) at sql_select.cc:181
#27 0x080c08af in mysql_execute_command (thd=0xa3ad000) at sql_parse.cc:2985
#28 0x080c3699 in mysql_parse (thd=0xa3ad000, inBuf=0xa3c4010 "insert into t1 select rand() from t1", length=171626556) at sql_parse.cc:4374
#29 0x080bd5ef in dispatch_command (command=COM_QUERY, thd=0xa3ad000, packet=0xa3af001 "insert into t1 select rand() from t1", packet_length=37)
    at sql_parse.cc:1530
#30 0x080bcf8b in do_command (thd=0xa3ad000) at sql_parse.cc:1331
#31 0x080bc59d in handle_one_connection (arg=0x0) at sql_parse.cc:1063
#32 0x28414902 in pthread_mutexattr_init () from /usr/lib/libpthread.so.1

How to repeat:
--disable_warnings
drop table if exists t1;
--enable_warnings

create table t1 (a varchar(19));

insert into t1 select rand();
insert into t1 select rand() from t1;
insert into t1 select rand() from t1;
insert into t1 select rand() from t1;
insert into t1 select rand() from t1;

Suggested fix:
-
[28 Nov 2006 16:56] MySQL Verification Team
Thank you for the bug report.

Server version: 5.1.14-beta-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> --disable_warnings
mysql> drop table if exists t1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> --enable_warnings
mysql> 
mysql> create table t1 (a varchar(19));
Query OK, 0 rows affected (0.01 sec)

mysql> 
mysql> insert into t1 select rand();
Query OK, 1 row affected (0.02 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> insert into t1 select rand() from t1;
Query OK, 1 row affected (0.00 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> insert into t1 select rand() from t1;
ERROR 2013 (HY000): Lost connection to MySQL server during query
------------------------------------------------------------------
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.32-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> --disable_warnings
mysql> drop table if exists t1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> --enable_warnings
mysql> 
mysql> create table t1 (a varchar(19));
Query OK, 0 rows affected (0.00 sec)

mysql> 
mysql> insert into t1 select rand();
Query OK, 1 row affected (0.01 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> insert into t1 select rand() from t1;
Query OK, 1 row affected (0.01 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> insert into t1 select rand() from t1;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> 
------------------------------------------------------------------
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.23-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> --disable_warnings
mysql> drop table if exists t1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> --enable_warnings
mysql> 
mysql> create table t1 (a varchar(19));
Query OK, 0 rows affected (0.01 sec)

mysql> 
mysql> insert into t1 select rand();
Query OK, 1 row affected (0.01 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> insert into t1 select rand() from t1;
Query OK, 1 row affected (0.00 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> insert into t1 select rand() from t1;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>
[19 Dec 2007 10:43] 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/40187

ChangeSet@1.2546, 2007-12-19 11:45:48+01:00, mhansson@linux-st28.site +3 -0
  Bug#24657: debug assertation fails (string store)
  
  sprintf is used to insert DOUBLE values into VARCHAR columns, but it
  was assumed that sprintf would write only 1 byte for a positive number
  n < 1. In realtity it needs two, one for leading zero and one for decimal
  point. Fixed by making the number 2.
[10 Jan 2008 9:49] Martin Hansson
This bug got fixed along with Bug#26788, so there's no need to push this patch.

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

Page generated in 0.056 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.