Skip to content

Race condition that causes crash at startup #1640

Open
@renecannao

Description

@renecannao

This is a very rare condition that can happen on any version of 1.4.x .
Thread HGCU_thread_run is initialized in the constructor of MySQL_HostGroups_Manager, and tried to use a lock yet not initialized.

Version 2.0 is not affected because by this bug.

Below an extract from error log:

2018-08-10 10:28:23 [INFO] Starting ProxySQL
2018-08-10 10:28:23 [INFO] Sucessfully started
2018-08-10 10:28:23 [INFO] Angel process started ProxySQL process 29650
Standard ProxySQL Cluster rev. 0.1.0702 -- ProxySQL_Cluster.cpp -- Tue Aug  7 12:48:36 2018
Standard ProxySQL Statistics rev. 1.4.1027 -- ProxySQL_Statistics.cpp -- Tue Aug  7 12:48:36 2018
Standard ProxySQL HTTP Server Handler rev. 1.4.1031 -- ProxySQL_HTTP_Server.cpp -- Tue Aug  7 12:48:36 2018
Error: signal 11:
proxysql(_Z13crash_handleri+0x1a)[0x558f9feec02a]
/lib/x86_64-linux-gnu/libc.so.6(+0x33060)[0x7f0bb8679060]
/lib/x86_64-linux-gnu/libpthread.so.0(pthread_mutex_lock+0x0)[0x7f0bb9fb0b20]
proxysql(+0x70fa3)[0x558f9ff01fa3]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0xb9e6f)[0x7f0bb8fb9e6f]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7494)[0x7f0bb9fae494]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7f0bb872eacf]
2018-08-10 10:28:23 main.cpp:910:ProxySQL_daemonize_phase3(): [ERROR] ProxySQL crashed. Restarting!

and backtrace from 1.4.10 on Debian Stretch:

(gdb) bt full
#0  __GI___pthread_mutex_lock (mutex=mutex@entry=0x218) at ../nptl/pthread_mutex_lock.c:67
        __PRETTY_FUNCTION__ = "__pthread_mutex_lock"
        type = <optimized out>
        id = <optimized out>
#1  0x0000558f9ff01fa3 in wqueue<MySQL_Connection*>::remove (this=0x200) at ../include/wqueue.h:54
        item = <optimized out>
#2  HGCU_thread_run () at MySQL_HostGroups_Manager.cpp:69
        myconn = 0x0
        statuses = <optimized out>
        ret = <optimized out>
        i = <optimized out>
        l = <optimized out>
        conn_array = <optimized out>
#3  0x00007f0bb8fb9e6f in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#4  0x00007f0bb9fae494 in start_thread (arg=0x7f0bb81ff700) at pthread_create.c:333
        __res = <optimized out>
        pd = 0x7f0bb81ff700
        now = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {139688310470400, -8317144122840003601, 0, 140722633325727, 0, 139688346026048, 
                8251968096506792943, 8251969496577657839}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, 
              cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#5  0x00007f0bb872eacf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions