Bug #40761 | LEFT JOIN on inline view crashes server | ||
---|---|---|---|
Submitted: | 15 Nov 2008 19:17 | Modified: | 28 Jan 2009 21:38 |
Reporter: | Robert Hunt | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S2 (Serious) |
Version: | 5.1.29/5.0/5.1/6.0 | OS: | Windows (WinXP (Intel-32)/Linux) |
Assigned to: | Gleb Shchepa | CPU Architecture: | Any |
[15 Nov 2008 19:17]
Robert Hunt
[15 Nov 2008 19:43]
MySQL Verification Team
Thank you for the bug report. Would be nice if you provide a repeatable test case with tables and data which allow to run the offended query, that file could be private if you want. Thanks in advance.
[15 Nov 2008 19:53]
MySQL Verification Team
I was able to repeat even with empty tables with 2 weeks older Windows server, however looks a quite different call stack: mysqld.exe!_NMSG_WRITE(int rterrnum=0x0000000a) Line 195 C mysqld.exe!abort() Line 44 + 0x7 C mysqld.exe!_assert(const char * expr=0x00bed4d4, const char * filename=0x00bed4c8, unsigned int lineno=0x000005b6) Line 306 C mysqld.exe!decimal_bin_size(int precision=0x00000000, int scale=0x00000000) Line 1462 + 0x28 C mysqld.exe!my_decimal_get_binary_size(unsigned int precision=0x00000000, unsigned int scale=0x00000000) Line 217 + 0xd C++ mysqld.exe!Field_new_decimal::Field_new_decimal(unsigned int len_arg=0x00000001, bool maybe_null_arg=true, const char * name=0x01f11298, unsigned char dec_arg=0x00, bool unsigned_arg=false) Line 2490 + 0x14 C++ mysqld.exe!Item_sum::create_tmp_field(bool group=false, st_table * table=0x01f170a0, unsigned int convert_blob_length=0x00000000) Line 504 + 0x46 C++ mysqld.exe!Item_sum_hybrid::create_tmp_field(bool group=false, st_table * table=0x01f170a0, unsigned int convert_blob_length=0x00000000) Line 710 + 0x14 C++ mysqld.exe!create_tmp_field(THD * thd=0x01ed71e8, st_table * table=0x01f170a0, Item * item=0x01f11168, Item::Type type=SUM_FUNC_ITEM, Item * * * copy_func=0x038edc90, Field * * from_field=0x01f17a54, Field * * default_field=0x01f179ec, bool group=false, bool modify_item=false, bool table_cant_handle_bit_fields=false, bool make_copy_field=false, unsigned int convert_blob_length=0x00000000) Line 9437 + 0x1c C++ mysqld.exe!create_tmp_table(THD * thd=0x01ed71e8, TMP_TABLE_PARAM * param=0x01f15598, List<Item> & fields={...}, st_order * group=0x00000000, bool distinct=false, bool save_sum_fields=true, unsigned __int64 select_options=0x0000000090045a00, unsigned __int64 rows_limit=0xffffffffffffffff, char * table_alias=0x01f14300) Line 9864 + 0xbd C++ mysqld.exe!select_union::create_result_table(THD * thd_arg=0x01ed71e8, List<Item> * column_types=0x01f0f2a4, bool is_union_distinct=false, unsigned __int64 options=0x0000000090045a00, const char * alias=0x01f14300) Line 124 + 0x2c C++ mysqld.exe!mysql_derived_prepare(THD * thd=0x01ed71e8, st_lex * lex=0x01ed8208, TABLE_LIST * orig_table_list=0x01f14328) Line 171 + 0x27 C++ mysqld.exe!mysql_handle_derived(st_lex * lex=0x01ed8208, bool (THD *, st_lex *, TABLE_LIST *)* processor=0x0040972d) Line 56 + 0x17 C++ mysqld.exe!open_and_lock_tables_derived(THD * thd=0x01ed71e8, TABLE_LIST * tables=0x01f14328, bool derived=true) Line 4974 + 0x19 C++ mysqld.exe!open_and_lock_tables(THD * thd=0x01ed71e8, TABLE_LIST * tables=0x01f14328) Line 1532 + 0xf C++ mysqld.exe!execute_sqlcom_select(THD * thd=0x01ed71e8, TABLE_LIST * all_tables=0x01f14328) Line 4793 + 0xd C++ mysqld.exe!mysql_execute_command(THD * thd=0x01ed71e8) Line 2136 + 0xd C++ mysqld.exe!mysql_parse(THD * thd=0x01ed71e8, const char * inBuf=0x01efef60, unsigned int length=0x000006d8, const char * * found_semicolon=0x038efd00) Line 5727 + 0x9 C++ mysqld.exe!dispatch_command(enum_server_command command=COM_QUERY, THD * thd=0x01ed71e8, char * packet=0x01ef6eb1, unsigned int packet_length=0x000006d8) Line 1152 + 0x1e C++ mysqld.exe!do_command(THD * thd=0x01ed71e8) Line 809 + 0x1b C++ mysqld.exe!handle_one_connection(void * arg=0x01ed71e8) Line 1115 + 0x9 C++ mysqld.exe!pthread_start(void * param=0x01220df8) Line 85 + 0x9 C mysqld.exe!_threadstart(void * ptd=0x01eb1048) Line 196 + 0xd C kernel32.dll!7c80b713()
[15 Nov 2008 20:00]
MySQL Verification Team
The released version 5.1.29 with empty tables don't crash: 01' ), ifNull( -> stc.updated, te.updated ) desc, te.nascency; Empty set (0.13 sec)
[15 Nov 2008 22:33]
MySQL Verification Team
Thank you for the feedback.
[16 Nov 2008 0:03]
MySQL Verification Team
Repeatable on 5.1.29 released version on Windows however today bzr source server on Ubuntu 64-bit shows an assertion. Repeatable with MyISAM engine too: Version: '5.0.74-debug' socket: '/tmp/mysql.sock' port: 3306 Source distribution mysqld: decimal.c:1456: decimal_bin_size: Assertion `scale >= 0 && precision > 0 && scale <= precision' failed. 081115 21:00:03 - mysqld got signal 6 ; 081115 21:23:20 [Note] 5.1/libexec/mysqld: ready for connections. Version: '5.1.31-debug' socket: '/tmp/mysql.sock' port: 3306 Source distribution mysqld: decimal.c:1462: decimal_bin_size: Assertion `scale >= 0 && precision > 0 && scale <= precision' failed. 081115 21:24:17 - mysqld got signal 6 ; Version: '6.0.9-alpha-debug' socket: '/tmp/mysql.sock' port: 3306 Source distribution mysqld: decimal.c:1445: decimal_bin_size: Assertion `scale >= 0 && precision > 0 && scale <= precision' failed. 081115 21:54:49 - mysqld got signal 6 ;
[12 Dec 2008 14:35]
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/61507 2748 Gleb Shchepa 2008-12-12 Bug #40761: Assert on sum function on IF(..., CAST(longtext AS UNSIGNED), signed_val) (was: LEFT JOIN on inline view crashes server) Select from a LONGTEXT column wrapped with an expression like "IF(..., CAST(longtext_column AS UNSIGNED), smth_signed)" failed an assertion or crashed the server. IFNULL function was affected too. LONGTEXT column item has a maximum length of 32^2-1 bytes, at the same time this is a maximum possible length of any MySQL item. CAST(longtext_column AS UNSIGNED) returns some unsigned numeric result of length 32^2-1, so the result of IF/IFNULL function of this number and some other signed number will have text length of (32^2-1)+1=32^2 (one byte for the minus sign) - there is integer overflow, and the length is equal to zero. That caused assert/crash. CAST AS UNSIGNED function has been modified to limit maximal length of resulting number to 67 (maximal length of DECIMAL and two characters for minus sign and dot).
[6 Jan 2009 13:57]
Bugs System
Pushed into 5.0.76 (revid:joro@sun.com-20090105160414-8q9j4bi1klkfwiup) (version source revid:azundris@mysql.com-20081230114734-nmsc37ak330zlygn) (merge vers: 5.0.76) (pib:6)
[9 Jan 2009 1:20]
Paul DuBois
Noted in 5.0.76 changelog. IF(..., CAST(longtext_val AS UNSIGNED), signed_val) as an argument to an aggregate function could cause an assertion failure. Setting report to NDI pending push into 5.1.x/6.0.x.
[15 Jan 2009 6:36]
Bugs System
Pushed into 5.1.31 (revid:joro@sun.com-20090115053147-tx1oapthnzgvs1ro) (version source revid:azundris@mysql.com-20081230114838-cn52tu180wcrvh0h) (merge vers: 5.1.31) (pib:6)
[15 Jan 2009 16:33]
Paul DuBois
Noted in 5.1.31 changelog. Setting report to NDI pending push into 6.0.x.
[19 Jan 2009 11:22]
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:00]
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 14:50]
Jon Stephens
Setting status back to NDI pending merge to 6.0 tree.
[19 Jan 2009 16:06]
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:53]
Bugs System
Pushed into 6.0.10-alpha (revid:joro@sun.com-20090119171328-2hemf2ndc1dxl0et) (version source revid:azundris@mysql.com-20081230114916-c290n83z25wkt6e4) (merge vers: 6.0.9-alpha) (pib:6)
[28 Jan 2009 21:38]
Paul DuBois
Noted in 6.0.10 changelog.