Bug #28666 CREATE EVENT ... EVERY 0 SECOND let server crash
Submitted: 25 May 2007 8:27 Modified: 2 Jun 2007 13:17
Reporter: Horst Hunger Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S1 (Critical)
Version:5.1.19 OS:Linux (Suse 10.1)
Assigned to: Andrey Hristov CPU Architecture:Any

[25 May 2007 8:27] Horst Hunger
Description:
the following sql statement let the server crash:

CREATE EVENT ev_create_11462 ON SCHEDULE EVERY 0 SECOND
            DO BEGIN
               SET @evname = 'ev_create_11462';
               SET @cnt = 0;
               SELECT count(*) into @cnt from event_log where ev_nm = @evname ;
               INSERT INTO event_log VALUES (NULL,@evname,@cnt+1,current_timestamp());
               END;|
See attached test. 
The backtrace:

warning: Can't read pathname for load map: Eingabe-/Ausgabefehler.
Reading symbols from /lib/libz.so.1...done.
Loaded symbols for /lib/libz.so.1
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libpthread.so.0...done.
Loaded symbols for /lib/libpthread.so.0
Reading symbols from /lib/librt.so.1...done.
Loaded symbols for /lib/librt.so.1
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
#0  0xffffe410 in __kernel_vsyscall ()
(gdb) bt
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7f635f6 in pthread_kill () from /lib/libpthread.so.0
#2  0x0842f033 in write_core (sig=6) at stacktrace.c:229
#3  0x08275188 in handle_segfault (sig=6) at mysqld.cc:2237
#4  <signal handler called>
#5  0xffffe410 in __kernel_vsyscall ()
#6  0xb7deb7d0 in raise () from /lib/libc.so.6
#7  0xb7decea3 in abort () from /lib/libc.so.6
#8  0xb7de501b in __assert_fail () from /lib/libc.so.6
#9  0x084681a5 in Events::create_event (thd=0x89c9500, parse_data=0x8a159c8,
    if_not_exists=false) at events.cc:382
#10 0x08289bb3 in mysql_execute_command (thd=0x89c9500) at sql_parse.cc:3209
#11 0x0828def4 in mysql_parse (thd=0x89c9500,
    inBuf=0x8a15818 "CREATE EVENT ev_create_11462 ON SCHEDULE EVERY 0 SECOND\nDO BEGIN\nSET @evname = 'ev_create_11462';\nSET @cnt = 0;\nSELECT count(*) into @cnt from event_log where ev_nm = @evname ;\nINSERT INTO event_log V"..., length=252,
    found_semicolon=0xb74a0320) at sql_parse.cc:5355
#12 0x0828ea28 in dispatch_command (command=COM_QUERY, thd=0x89c9500,
    packet=0x8a0d7b9 "CREATE EVENT ev_create_11462 ON SCHEDULE EVERY 0 SECOND\nDO BEGIN\nSET @evname = 'ev_create_11462';\nSET @cnt = 0;\nSELECT count(*) into @cnt from event_log where ev_nm = @evname ;\nINSERT INTO event_log V"..., packet_length=254)
    at sql_parse.cc:906
#13 0x0828fbd3 in do_command (thd=0x89c9500) at sql_parse.cc:667
#14 0x0827d852 in handle_one_connection (arg=0x89c9500) at sql_connect.cc:1091
#15 0xb7f5f34b in start_thread () from /lib/libpthread.so.0
#16 0xb7e8065e in clone () from /lib/libc.so.6
(gdb) q

How to repeat:
copy test into t, create a result file in r by "touch ev_bug2.result" and execute

perl mysql-test-run.pl ev_bug2
[25 May 2007 11:06] MySQL Verification Team
Thank you for the bug report.

[New Thread -1262695536 (LWP 5269)]
070525  8:04:02 [Note] Event Scheduler: Loaded 0 events
070525  8:04:02 [Note] /home/miguel/dbs/5.1/libexec/mysqld: ready for connections.
Version: '5.1.19-beta-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
[New Thread -1262896240 (LWP 5327)]
mysqld: events.cc:382: static bool Events::create_event(THD*, Event_parse_data*, bool): Assertion `parse_data->expression || parse_data->execute_at' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread -1262896240 (LWP 5327)]
0x0094f402 in __kernel_vsyscall ()
(gdb) bt full
#0  0x0094f402 in __kernel_vsyscall ()
No symbol table info available.
#1  0x00138d40 in raise () from /lib/libc.so.6
No symbol table info available.
#2  0x0013a591 in abort () from /lib/libc.so.6
No symbol table info available.
#3  0x0013238b in __assert_fail () from /lib/libc.so.6
No symbol table info available.
#4  0x084699df in Events::create_event (thd=0x9e5b680, parse_data=0x9e87220, if_not_exists=false) at events.cc:382
        ret = 166052928
        _db_func_ = 0x874a3b8 "mysql_execute_command"
        _db_file_ = 0x8749c90 "sql_parse.cc"
        _db_level_ = 4
        _db_framep_ = (char **) 0xfffffff
        __PRETTY_FUNCTION__ = "static bool Events::create_event(THD*, Event_parse_data*, bool)"
#5  0x0828c4a1 in mysql_execute_command (thd=0x9e5b680) at sql_parse.cc:3209
        if_not_exists = false
<cut>
[25 May 2007 11:14] Andrey Hristov
Verified here
[25 May 2007 13:45] 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/27342

ChangeSet@1.2515, 2007-05-25 14:46:22+02:00, andrey@whirlpool.mysql.com +3 -0
  Fix for bug#28666 CREATE EVENT ... EVERY 0 SECOND let server crash
  
  A missing check for zero value of interval was added.
[1 Jun 2007 19:24] Bugs System
Pushed into 5.1.20-beta
[2 Jun 2007 13:17] Jon Stephens
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 bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Documented bugfix in 5.1.20 changelog.