Bug #41437 | Value stored in 'case' lacks charset, causes segfault | ||
---|---|---|---|
Submitted: | 12 Dec 2008 15:03 | Modified: | 28 Jan 2009 21:34 |
Reporter: | Adam Erickson | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 5.0/5.1/6.0 | OS: | Any (2.6.18-53.1.14.el5 (SMP, 64 bit)) |
Assigned to: | Georgi Kodinov | CPU Architecture: | Any |
Tags: | case, character set, crash, mysqld, segfault, strict_trans_tables |
[12 Dec 2008 15:03]
Adam Erickson
[12 Dec 2008 16:22]
MySQL Verification Team
Thank you for the bug report. On my first test on Windows I was able to crash 5.1.29 but not 5.1.30. Could you please provide your my.cnf?. Thanks in advance. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.1.29-rc-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> SELECT @testMe := case @@hostname when 'this' then 'that' end as -> 'Foo'; +------+ | Foo | +------+ | NULL | +------+ 1 row in set (0.05 sec) mysql> SELECT IF(@testMe != database(), 'True','False') as 'Check'; ERROR 2013 (HY000): Lost connection to MySQL server during query mysql> C:\temp\mysql-5.1.30-win32>bin\mysql -uroot test Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.30-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> SELECT @testMe := case @@hostname when 'this' then 'that' end as 'Foo'; +------+ | Foo | +------+ | NULL | +------+ 1 row in set (0.03 sec) mysql> SELECT IF(@testMe != database(), 'True','False') as 'Check'; +-------+ | Check | +-------+ | False | +-------+ 1 row in set (0.03 sec) mysql> exit Bye
[12 Dec 2008 17:12]
MySQL Verification Team
Thank you for the feedback. Now I was able to repeat adding to my.cnf file: sql_mode=strict_trans_tables Repeatable om 5.0 and 6.0 too. c:\dbs>c:\dbs\5.1\bin\mysqld --defaults-file=c:\dbs\5.1\my.ini --standalone --console 081212 15:04:42 InnoDB: Started; log sequence number 0 57253 081212 15:04:42 [Note] Event Scheduler: Loaded 0 events 081212 15:04:42 [Note] c:\dbs\5.1\bin\mysqld: ready for connections. Version: '5.1.31-nt-debug-log' socket: '' port: 3510 Source distribution 081212 15:05:17 - mysqld got exception 0xc0000005 ; This could be because you hit a bug. It is also possible that this binary or one of the libraries it was linked against is corrupt, improperly built, or misconfigured. This error can also be caused by malfunctioning hardware. We will try our best to scrape up some info that will hopefully help diagnose the problem, but since we have already crashed, something is definitely wrong and this may fail. key_buffer_size=8388572 read_buffer_size=131072 max_used_connections=1 max_threads=151 threads_connected=1 It is possible that mysqld could use up to key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 337709 K bytes of memory Hope that's ok; if not, decrease some variables in the equation. thd: 0x1eb0f78 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... 004483E1 mysqld.exe!String::charset()[sql_string.h:92] 004F9BE7 mysqld.exe!Item_func_sysconst::safe_charset_converter()[item_strfunc.cc:1785] 0047FE17 mysqld.exe!agg_item_charsets()[item.cc:1709] 004AF8D0 mysqld.exe!Item_func::agg_arg_charsets()[item_func.h:186] 0049ADAB mysqld.exe!Item_bool_func2::fix_length_and_dec()[item_cmpfunc.cc:481] 004D5226 mysqld.exe!Item_func::fix_fields()[item_func.cc:198] 004D5065 mysqld.exe!Item_func::fix_fields()[item_func.cc:171] 004A0FE4 mysqld.exe!Item_func_if::fix_fields()[item_cmpfunc.cc:2295] 00617153 mysqld.exe!setup_fields()[sql_base.cc:7398] 006B385E mysqld.exe!JOIN::prepare()[sql_select.cc:502] 006B9658 mysqld.exe!mysql_select()[sql_select.cc:2351] 006B3219 mysqld.exe!handle_select()[sql_select.cc:269] 00679B49 mysqld.exe!execute_sqlcom_select()[sql_parse.cc:4890] 00672578 mysqld.exe!mysql_execute_command()[sql_parse.cc:2184] 0067BBF1 mysqld.exe!mysql_parse()[sql_parse.cc:5789] 006706CE mysqld.exe!dispatch_command()[sql_parse.cc:1200] 0066FDB7 mysqld.exe!do_command()[sql_parse.cc:857] 00780AF4 mysqld.exe!handle_one_connection()[sql_connect.cc:1115] 008498A6 mysqld.exe!pthread_start()[my_winthread.c:85] 009B93B7 mysqld.exe!_threadstart()[thread.c:196] 7C80B713 kernel32.dll!GetModuleFileNameA() Trying to get some variables. Some pointers may be invalid and cause the dump to abort... thd->query at 01EFEC58=SELECT IF(@testMe != database(), 'True','False') as 'Check' thd->thread_id=1 thd->killed=NOT_KILLED The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains information that should help you find out what is causing the crash.
[7 Jan 2009 16:57]
Georgi Kodinov
Can't reproduce with the latest 5.0-main. Tried : set SQL_MODE=strict_trans_tables; SELECT @testMe := case @@hostname when 'this' then 'that' end as 'Foo'; Foo NULL SELECT IF(@testMe != database(), 'True','False') as 'Check'; Check False
[7 Jan 2009 16:58]
Alexander Keremidarski
Can't repeat it on Fedora 10 with 5.0 compiled from bk-internal.mysql.com/bzrroot/server/mysql-5.0/ revno: 2724 committer: Georgi Kodinov <joro@sun.com> branch nick: fix-5.0-bugteam timestamp: Mon 2009-01-05 18:04:14 +0200
[8 Jan 2009 2:51]
MySQL Verification Team
simpler testcase: mysql -uroot -e"select @z:='1',@z=database()"
[8 Jan 2009 13:05]
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/62682 2725 Georgi Kodinov 2009-01-08 Bug #41437: Value stored in 'case' lacks charset, causes segfault Character set conversion functions were not expecting NULL values returned when converting to string. As a result they were dereferencing the NULL returned by ::val_str() in such cases. Fixed by checking and returning a constant Item_null instead of Item_string.
[9 Jan 2009 11:51]
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/62803 2725 Georgi Kodinov 2009-01-09 Bug #41437: Value stored in 'case' lacks charset, causes segfault When substituting system constant functions with a constant result the server was not expecting that the function may return NULL. Fixed by checking for NULL and returning Item_null (in the relevant collation) if the result of the system constant function was NULL.
[14 Jan 2009 9:33]
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/63197 2748 He Zhenxing 2009-01-14 [merge] Auto merge
[15 Jan 2009 6:38]
Bugs System
Pushed into 5.1.31 (revid:joro@sun.com-20090115053147-tx1oapthnzgvs1ro) (version source revid:davi.arnaut@sun.com-20090113150631-y84w12o2zmh7j3qd) (merge vers: 5.1.31) (pib:6)
[15 Jan 2009 6:44]
Bugs System
Pushed into 5.0.77 (revid:joro@sun.com-20090115043518-cn6jeeg78j6mupp3) (version source revid:azundris@mysql.com-20090109220607-5ygzffhznqomnf8k) (merge vers: 5.0.76) (pib:6)
[19 Jan 2009 11:25]
Bugs System
Pushed into 5.1.31-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090119095303-uwwvxiibtr38djii) (version source revid:tomas.ulin@sun.com-20090115073240-1wanl85vlvw2she1) (merge vers: 5.1.31-ndb-6.2.17) (pib:6)
[19 Jan 2009 13:03]
Bugs System
Pushed into 5.1.31-ndb-6.3.21 (revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (version source revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (merge vers: 5.1.31-ndb-6.3.21) (pib:6)
[19 Jan 2009 16:09]
Bugs System
Pushed into 5.1.31-ndb-6.4.1 (revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (version source revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (merge vers: 5.1.31-ndb-6.4.1) (pib:6)
[20 Jan 2009 18:56]
Bugs System
Pushed into 6.0.10-alpha (revid:joro@sun.com-20090119171328-2hemf2ndc1dxl0et) (version source revid:igor@mysql.com-20090110022839-s9xt3acu2yq33n26) (merge vers: 6.0.10-alpha) (pib:6)
[28 Jan 2009 21:34]
Paul DuBois
Noted in 5.0.78, 5.1.31, 6.0.10 changelogs. When substituting system constant functions with a constant result, the server was not expecting NULL function return values and could crash.
[9 Jun 2009 19:01]
Paul DuBois
Noted in 5.0.74sp1 changelog.
[11 Dec 2009 10:57]
MySQL Verification Team
another testcase: mysql -uroot -p drop table if exists test.t1,test.v1; create table test.t1(id varchar(255))engine=myisam; create or replace view test.v1 as select id from test.t1 where id=database(); show create table test.v1; #crashes on <5.0.78