Changeset 804c0ff


Ignore:
Timestamp:
Jan 15, 2021, 2:23:08 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
8c43d05
Parents:
b8b0de0c
Message:

Simplified abort handling in the case of concurrent abort.
I used to try to be fancy, now a lock-free algorithm just directly calls libc-abort on ANY subsequent/concurrent calls.

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel.cfa

    rb8b0de0c r804c0ff  
    624624// Unexpected Terminating logic
    625625//=============================================================================================
    626 static __spinlock_t kernel_abort_lock;
    627 static bool kernel_abort_called = false;
     626
     627extern "C" {
     628        extern void __cfaabi_real_abort(void);
     629}
     630static volatile bool kernel_abort_called = false;
    628631
    629632void * kernel_abort(void) __attribute__ ((__nothrow__)) {
    630633        // abort cannot be recursively entered by the same or different processors because all signal handlers return when
    631634        // the globalAbort flag is true.
    632         lock( kernel_abort_lock __cfaabi_dbg_ctx2 );
     635        bool first = __atomic_test_and_set( &kernel_abort_called, __ATOMIC_SEQ_CST);
     636
     637        // first task to abort ?
     638        if ( !first ) {
     639                // We aren't the first to abort.
     640                // I give up, just let C handle it
     641                __cfaabi_real_abort();
     642        }
    633643
    634644        // disable interrupts, it no longer makes sense to try to interrupt this processor
    635645        disable_interrupts();
    636 
    637         // first task to abort ?
    638         if ( kernel_abort_called ) {                    // not first task to abort ?
    639                 unlock( kernel_abort_lock );
    640 
    641                 sigset_t mask;
    642                 sigemptyset( &mask );
    643                 sigaddset( &mask, SIGALRM );            // block SIGALRM signals
    644                 sigaddset( &mask, SIGUSR1 );            // block SIGALRM signals
    645                 sigsuspend( &mask );                            // block the processor to prevent further damage during abort
    646                 _exit( EXIT_FAILURE );                          // if processor unblocks before it is killed, terminate it
    647         }
    648         else {
    649                 kernel_abort_called = true;
    650                 unlock( kernel_abort_lock );
    651         }
    652646
    653647        return __cfaabi_tls.this_thread;
  • libcfa/src/interpose.cfa

    rb8b0de0c r804c0ff  
    284284}
    285285
     286extern "C" {
     287        void __cfaabi_real_abort(void) {
     288                __cabi_libc.abort();
     289        }
     290}
     291
    286292void sigHandler_segv( __CFA_SIGPARMS__ ) {
    287293                if ( sfp->si_addr == 0p ) {
Note: See TracChangeset for help on using the changeset viewer.