Bug #81193 MySQL crashed when make connections from daemon plugin
Submitted: 25 Apr 2016 11:56 Modified: 24 May 2017 16:03
Reporter: Fangxin Flou (OCA) Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Connection Handling Severity:S3 (Non-critical)
Version:5.5.x OS:Any
Assigned to: CPU Architecture:Any

[25 Apr 2016 11:56] Fangxin Flou
Description:
A succesful mysql_real_connect in daemon plugin thread get the following errors and mysql creashed.

160425 19:40:17 [Note] /usr/local/onesql5542/bin/mysqld: ready for connections.
Version: '5.5.42'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
11:42:48 UTC - mysqld got signal 11 ;
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=8388608
read_buffer_size=131072
max_used_connections=1
max_threads=151
thread_count=1
connection_count=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 338498 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0
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...
stack_bottom = 0 thread_stack 0x40000
/usr/local/onesql5542/bin/mysqld(my_print_stacktrace+0x2e)[0x76501e]
/usr/local/onesql5542/bin/mysqld(handle_fatal_signal+0x493)[0x653143]
/lib64/libpthread.so.0[0x3b9cc0f710]
/usr/local/onesql5542/bin/mysqld(thr_alarm+0xc0)[0x7679c0]
/usr/local/onesql5542/bin/mysqld(mysql_real_connect+0x996)[0x639576]
/usr/local/onesql5542/bin/mysqld(_Z9LogonMYDBP11_MYDATABASEPKc+0x291)[0x8c1af1]
/usr/local/onesql5542/bin/mysqld(_Z13getJSONStatusPv+0x2bf)[0x8bb20f]
/usr/local/onesql5542/bin/mysqld(oneagent_dataload+0x90)[0x8bb300]
/lib64/libpthread.so.0[0x3b9cc079d1]
/lib64/libc.so.6(clone+0x6d)[0x3b9c8e8b6d]
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.
160425 19:42:48 mysqld_safe Number of processes running now: 0

How to repeat:
make a sucessful mysql_real_connect in daemon plugin thread.

Suggested fix:
in mysys/thr_alarm.c

my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data)

orginal code:

  alarm_data->alarmed=0;
  alarm_data->thread=    current_my_thread_var->pthread_self;
  alarm_data->thread_id= current_my_thread_var->id;
  queue_insert_safe(&alarm_queue, (uchar*) alarm_data);

changed to:

  alarm_data->alarmed=0;
  if (current_my_thread_var)
  {
  alarm_data->thread=    current_my_thread_var->pthread_self;
  alarm_data->thread_id= current_my_thread_var->id;
  }
  queue_insert_safe(&alarm_queue, (uchar*) alarm_data);

Threads from daemon thread does not have current_my_thread_var
[24 Apr 2017 16:03] Sinisa Milivojevic
Hi!

I need the answers to several questions , before I can conclude whether it is a bug or not.

* How did you manage to cause zero pointer on thread in the thr_alarm()
* Are you using our build of the server
* Are you using our mysql CLI or our libmysqlclient libraries 
* If not, can you try our binaries
* I have tried to crash 5.5 in daemon plugin, but did not succeed. How did you manage to do it ???  Also, what plugin exactly (name, version & release) are you using and is it a match to the server ??
Thank you very much in advance.
[25 May 2017 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".