• Shishir Jaiswal's avatar
    Bug #21467458 - UNINSTALL PLUGIN DAEMON_EXAMPLE CRASHES · 17387bc5
    Shishir Jaiswal authored
                    MYSQLD.
    
    DESCRIPTION
    ===========
    Crash occurs when daemon_example plugin is uninstalled
    immediately after its installed. This can be reproduced
    by installing and uninstalling the plugin repeatedly.
    
    ANALYSIS
    ========
    The daemon_example_plugin_deinit() function of the daemon
    example plugin calls pthread_cancel() but doesn't wait for
    the worker thread to actually complete before deallocating
    the data buffer and closing the file that it writes to.
    This is causing SEGFAULT!
    
    FIX
    ===
    Added a pthread_join() to wait for the thread to complete
    before doing the cleanup work.
    
    Removed a stray 'x' variable from the example code.
    
    NOTE
    ====
    Have made an entry in .opt file as given below:
    --plugin-dir=$DAEMONEXAMPLE_DIR
    
    This is done so that the program takes plugin directory as
    ../<dbg>/plugin/daemon_example/ instead of
    ../lib/plugin/
    17387bc5
daemon_example.cc 5.89 KB