Bug #7281 RAND(RAND) crashes server
Submitted: 14 Dec 2004 16:56 Modified: 21 Dec 2004 7:59
Reporter: Jan Kneschke Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1.7-max-nt/4.1.8 OS:Windows (Windows/Linux)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[14 Dec 2004 16:56] Jan Kneschke
Description:
SELECT  RAND(RAND); 

crashes server.

How to repeat:
SELECT  RAND(RAND); 

Suggested fix:
Server should not crash.
[14 Dec 2004 17:15] MySQL Verification Team
Thank you for the bug report.
[14 Dec 2004 20:01] MySQL Verification Team
This also happens on Linux 4.1.8 latest Bk source:

miguel@hegel:~/dbs/4.1$ libexec/mysqld
041214 17:56:37  InnoDB: Started; log sequence number 0 43634
libexec/mysqld: ready for connections.
Version: '4.1.8-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
mysqld: item.cc:554: virtual longlong Item_field::val_int(): Assertion `fixed == 1' failed.
mysqld got signal 6;
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=1073741824
read_buffer_size=67104768
max_used_connections=1
max_connections=500
threads_connected=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 1308702 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd=0x48f05650
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...
Cannot determine thread, fp=0xbe7fead8, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x8192edd
0x4018dbe5
0x402601b1
0x4018accb
0x4025fdf4
0x402615a8
0x4025956c
0x8112ede
0x8128bdc
0x81cd612
0x81d30aa
0x81d6c3e
0x81d2e8f
0x81a8935
0x81ae22b
0x81a727c
0x81a6ba1
0x81a600b
0x40187cc4
0x40313037
New value of fp=(nil) failed sanity check, terminating stack trace!
Please read http://dev.mysql.com/doc/mysql/en/Using_stack_trace.html and follow instructions on how to resolve the stack trace. Resolved
stack trace is much more helpful in diagnosing the problem, so please do 
resolve it
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x8c80fb0 = select rand(rand)
thd->thread_id=1
The manual page at http://www.mysql.com/doc/en/Crashing.html contains
information that should help you find out what is causing the crash.
miguel@hegel:~/dbs/4.1$
[14 Dec 2004 20:08] MySQL Verification Team
Below the call stack on 4.1.8 Windows:

>	mysqld.exe!_NMSG_WRITE(int rterrnum=10)  Line 221	C
 	mysqld.exe!abort()  Line 44 + 0x7	C
 	mysqld.exe!_assert(void * expr=0x0079f448, void * filename=0x0079f42c, unsigned int lineno=554)  Line 267	C
 	mysqld.exe!Item_field::val_int()  Line 554 + 0x20	C++
 	mysqld.exe!Item_func_rand::fix_fields(THD * thd=0x00e612f8, st_table_list * tables=0x00000000, Item * * ref=0x02f18964)  Line 1116 + 0x15	C++
 	mysqld.exe!setup_fields(THD * thd=0x00e612f8, Item * * ref_pointer_array=0x02f19398, st_table_list * tables=0x00000000, List<Item> & fields={...}, int set_query_id=1, List<Item> * sum_func_list=0x02f192f4, int allow_sum_func=1)  Line 2385 + 0x27	C++
 	mysqld.exe!JOIN::prepare(Item * * * rref_pointer_array=0x00e61530, st_table_list * tables_init=0x00000000, unsigned int wild_num=0, Item * conds_init=0x00000000, unsigned int og_num=0, st_order * order_init=0x00000000, st_order * group_init=0x00000000, Item * having_init=0x00000000, st_order * proc_param_init=0x00000000, st_select_lex * select_lex_arg=0x00e61444, st_select_lex_unit * unit_arg=0x00e61344)  Line 278 + 0xb1	C++
 	mysqld.exe!mysql_select(THD * thd=0x00e612f8, Item * * * rref_pointer_array=0x00e61530, st_table_list * tables=0x00000000, unsigned int wild_num=0, List<Item> & fields={...}, Item * conds=0x00000000, unsigned int og_num=0, st_order * order=0x00000000, st_order * group=0x00000000, Item * having=0x00000000, st_order * proc_param=0x00000000, unsigned long select_options=8669696, select_result * result=0x02f18988, st_select_lex_unit * unit=0x00e61344, st_select_lex * select_lex=0x00e61444)  Line 1564 + 0x34	C++
 	mysqld.exe!handle_select(THD * thd=0x00e612f8, st_lex * lex=0x00e61338, select_result * result=0x02f18988)  Line 193 + 0x87	C++
 	mysqld.exe!mysql_execute_command(THD * thd=0x00e612f8)  Line 2020 + 0x11	C++
 	mysqld.exe!mysql_parse(THD * thd=0x00e612f8, char * inBuf=0x02f18840, unsigned int length=17)  Line 4093 + 0x9	C++
 	mysqld.exe!dispatch_command(enum_server_command command=COM_QUERY, THD * thd=0x00e612f8, char * packet=0x02f10781, unsigned int packet_length=18)  Line 1477 + 0x1d	C++
 	mysqld.exe!do_command(THD * thd=0x00e612f8)  Line 1291 + 0x31	C++
 	mysqld.exe!handle_one_connection(void * arg=0x00e612f8)  Line 1023 + 0x9	C++
 	mysqld.exe!pthread_start(void * param=0x00e5e060)  Line 63 + 0x7	C
 	mysqld.exe!_threadstart(void * ptd=0x00e6f7c8)  Line 173 + 0xd	C
 	kernel32.dll!7c80b50b() 	
 	kernel32.dll!7c8399f3()
[21 Dec 2004 7:59] Ramil Kalimullin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

fixed in 4.1.9