• Sergei Golubchik's avatar
    fix ASAN+safemalloc builds · f6ecadfe
    Sergei Golubchik authored
    debug_sync refactoring introduced a statically instantiated object
    debug_sync_global of the structure st_debug_sync_globals.
    st_debug_sync_globals includes Hash_set<> which allocates memory
    in the constructor. sf_malloc() calls _my_thread_var()->dbug_id
    which is pthread_getspecific(THR_KEY_mysys), and THR_KEY_mysys is 0
    before pthread_key_create(). pthread_getspecific(0) returns a valid
    pointer, not EINVAL. And safemalloc dereferences it.
    
    let's statically initialize THR_KEY_mysys to -1, this makes
    pthread_getspecific(THR_KEY_mysys) to fail before pthread_key_create()
    is called.
    
    followup for 8885225d
    f6ecadfe
my_thr_init.c 17 KB