• meiravgri's avatar
    remove heap allocations from signal handlers. (#12655) · d27c7413
    meiravgri authored
    Using heap allocation during signal handlers is unsafe.
    This PR purpose is to replace all the heap allocations done within the signal
    handlers raised upon server crash and assertions.
    These were added in #12453.
    
    writeStacktraces(): allocates the stacktraces output array on the calling thread's
    stack and assigns the address to a global variable.
    It calls `ThreadsManager_runOnThreads()` that invokes `collect_stacktrace_data()`
    by each thread: each thread writes to a different location in the above array to allow
    sync writes.
    
    get_ready_to_signal_threads_tids(): instead of allocating the `tids` array, it receives it
    as a fixed size array parameter, allocated on on the stack of the calling function, and
    returns the number of valid threads. The array size is hard-coded to 50.
    
    `ThreadsManager_runOnThreads():` To avoid the outputs array allocation, the
    **callback signature** was changed. Now it should return void. This function return type
    has also changed to int - returns 1 if successful, and 0 otherwise.
    
    Other unsafe calls will be handled in following PRs
    d27c7413
debug.c 99.2 KB