Bug #68009 Floating point exception in "insert_events_waits_history_long"
Submitted: 2 Jan 2013 9:22 Modified: 10 Jan 2013 13:34
Reporter: Tianyin Xu Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S2 (Serious)
Version:5.5.28, 5.5.29 OS:Any
Assigned to: Marc ALFF CPU Architecture:Any

[2 Jan 2013 9:22] Tianyin Xu
Description:
Hi,

The symptom of this bug is similar as Bug #68008. But their root cause is very different. I don't know whether this one affects 5.6.9.

When having the following configuration settings in option files:

#my.cnf
loose-enable-performance-schema
performance_schema_events_waits_history_long_size=0

The server crashes with the log message:
Floating point exception (core dumped)

The root cause is the modular operation in the following function:

/* storage/perfschema/pfs_events_waits.cc */
121 void insert_events_waits_history_long(PFS_events_waits *wait)
122 {
123   uint index= PFS_atomic::add_u32(&events_waits_history_long_index, 1);
124 
125   index= index % events_waits_history_long_size;
126   if (index == 0)
127     events_waits_history_long_full= true;
128 
129   /* See related comment in insert_events_waits_history. */
130   copy_events_waits(&events_waits_history_long_array[index], wait);
131 }

The back-trace from GDB is attached as follows:

(gdb) r
Starting program: /home/tianyin/mysql-5.5.28/usr/local/mysql/bin/mysqld 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff6793700 (LWP 17817)]
[Thread 0x7ffff6793700 (LWP 17817) exited]

Program received signal SIGFPE, Arithmetic exception.
0x000000000086bbc0 in insert_events_waits_history_long (wait=0x7fffdb8352e8) at /home/tianyin/source_code/mysql-5.5.28/storage/perfschema/pfs_events_waits.cc:125
125	  index= index % events_waits_history_long_size;
(gdb) bt
#0  0x000000000086bbc0 in insert_events_waits_history_long (wait=0x7fffdb8352e8) at /home/tianyin/source_code/mysql-5.5.28/storage/perfschema/pfs_events_waits.cc:125
#1  0x000000000086ac74 in end_mutex_wait_v1 (locker=0x7fffdb8352d8, rc=0) at /home/tianyin/source_code/mysql-5.5.28/storage/perfschema/pfs.cc:1629
#2  0x0000000000845f8b in inline_mysql_mutex_lock (that=0x10f5760, src_file=0xb0d588 "/home/tianyin/source_code/mysql-5.5.28/mysys/my_open.c", src_line=137)
    at /home/tianyin/source_code/mysql-5.5.28/include/mysql/psi/mysql_thread.h:621
#3  0x000000000084621c in my_register_filename (fd=7, FileName=0x7fffffffd990 "/home/tianyin/mysql-5.5.28/usr/local/mysql/share/english/errmsg.sys", 
    type_of_file=FILE_BY_OPEN, error_message_number=29, MyFlags=0) at /home/tianyin/source_code/mysql-5.5.28/mysys/my_open.c:137
#4  0x000000000084604e in my_open (FileName=0x7fffffffd990 "/home/tianyin/mysql-5.5.28/usr/local/mysql/share/english/errmsg.sys", Flags=0, MyFlags=0)
    at /home/tianyin/source_code/mysql-5.5.28/mysys/my_open.c:52
#5  0x00000000006e2759 in inline_mysql_file_open (key=9, src_file=0xaa1010 "/home/tianyin/source_code/mysql-5.5.28/sql/derror.cc", src_line=119, 
    filename=0x7fffffffd990 "/home/tianyin/mysql-5.5.28/usr/local/mysql/share/english/errmsg.sys", flags=0, myFlags=0)
    at /home/tianyin/source_code/mysql-5.5.28/include/mysql/psi/mysql_file.h:1046
#6  0x00000000006e2bb1 in read_texts (file_name=0xaa1000 "errmsg.sys", language=0xa4ee60 "english", point=0x7fffffffdde0, error_messages=728)
    at /home/tianyin/source_code/mysql-5.5.28/sql/derror.cc:116
#7  0x00000000006e2a16 in init_errmessage () at /home/tianyin/source_code/mysql-5.5.28/sql/derror.cc:70
#8  0x0000000000548070 in init_common_variables () at /home/tianyin/source_code/mysql-5.5.28/sql/mysqld.cc:3360
#9  0x0000000000549636 in mysqld_main (argc=30, argv=0x10fbe48) at /home/tianyin/source_code/mysql-5.5.28/sql/mysqld.cc:4397
#10 0x0000000000543f24 in main (argc=1, argv=0x7fffffffe1d8) at /home/tianyin/source_code/mysql-5.5.28/sql/main.cc:25

Thanks,
Tianyin

How to repeat:
Add the following two lines in the configuration file my.cnf,

#/etc/mysql/my.cnf
loose-enable-performance-schema
performance_schema_events_waits_history_long_size=0

then start the mysqld, and you can see the crash:

$ ./bin/mysqld
Floating point exception (core dumped)

Suggested fix:
Similar as Bug #68008,

I can think about two workaround:

1. Check the value, i.e., events_waits_history_long_size, in the  "insert_events_waits_history_long" function;

2. Abandon the settings "performance_schema_events_waits_history_long_size=0" in the parsing function.
[2 Jan 2013 9:31] MySQL Verification Team
verified with 5.5.30.  5.6 is not affected.
[10 Jan 2013 13:34] Erlend Dahl
Duplicate of bug#68008.
[15 Jul 2020 7:58] John Golden
Drugs are regulated for fitness for all offers. The payment of the chance and https://customessaysreviews.com/writemypaper4me-org/ is visited for the volumes for all issues. The tapes manipulation or the engagement for the shadows for all flit ion and factors.
[5 Nov 2022 12:45] shine lee
If you are getting a "floating point exception" error when trying to start MySQL, it means that the MySQL binary is not compatible with the libraries it is linked against. This can happen if you upgrade your operating system without first upgrading MySQL.
It happened when I visited https://patronsurveys.com/www-publixsurvey-com/ for Publix Survey, which gives $1000.

To fix this, you will need to recompile MySQL from the source.