Changeset 210b8b3


Ignore:
Timestamp:
Mar 23, 2020, 6:15:33 PM (18 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast, new-ast-unique-expr
Children:
ae66348
Parents:
3a3b2b9
Message:

Added checks that the stack pointer is consistent when running and returning from a thread

Location:
libcfa/src/concurrency
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/invoke.h

    r3a3b2b9 r210b8b3  
    119119        };
    120120
     121        static inline struct __stack_t * __get_stack( struct $coroutine * cor ) { return (struct __stack_t*)(((uintptr_t)cor->stack.storage) & ((uintptr_t)-2)); }
     122
    121123        // struct which calls the monitor is accepting
    122124        struct __waitfor_mask_t {
  • libcfa/src/concurrency/kernel.cfa

    r3a3b2b9 r210b8b3  
    344344
    345345                /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
     346                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ) || thrd_dst->curr_cor == proc_cor, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too small.\n", thrd_dst ); // add escape condition if we are setting up the processor
     347                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit) || thrd_dst->curr_cor == proc_cor, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too large.\n", thrd_dst ); // add escape condition if we are setting up the processor
    346348
    347349                // set context switch to the thread that the processor is executing
     
    350352                // when __cfactx_switch returns we are back in the processor coroutine
    351353
     354                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit), "ERROR : Destination $thread %p has been corrupted.\n StackPointer too large.\n", thrd_dst );
     355                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ), "ERROR : Destination $thread %p has been corrupted.\n StackPointer too small.\n", thrd_dst );
    352356                /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    353357
     
    418422
    419423        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
     424        /* paranoid */ verifyf( ((uintptr_t)thrd_src->context.SP) < ((uintptr_t)__get_stack(thrd_src->curr_cor)->base ), "ERROR : Returning $thread %p has been corrupted.\n StackPointer too small.\n", thrd_src );
     425        /* paranoid */ verifyf( ((uintptr_t)thrd_src->context.SP) > ((uintptr_t)__get_stack(thrd_src->curr_cor)->limit), "ERROR : Returning $thread %p has been corrupted.\n StackPointer too large.\n", thrd_src );
    420426}
    421427
     
    764770        // Destroy the main processor and its context in reverse order of construction
    765771        // These were manually constructed so we need manually destroy them
    766         ^(mainProcessor->runner){};
    767         ^(mainProcessor){};
     772        ^(*mainProcessor){};
    768773
    769774        // Final step, destroy the main thread since it is no longer needed
    770775        // Since we provided a stack to this taxk it will not destroy anything
    771         ^(mainThread){};
     776        /* paranoid */ verify(mainThread->self_cor.stack.storage == (__stack_t*)(((uintptr_t)&storage_mainThreadCtx)| 0x1));
     777        ^(*mainThread){};
    772778
    773779        ^(__cfa_dbg_global_clusters.list){};
Note: See TracChangeset for help on using the changeset viewer.