Skip to content
  • Philippe Gerum's avatar
    cobalt/thread: fix SMP race with xnthread_join() · 5902ea95
    Philippe Gerum authored
    The situation below would cause a kernel crash on any earlier 3.x
    release, with ktask implemented in a dynamically loaded/unloaded
    module:
    
    CPU0:  rtdm_task_destroy(ktask)
           ...
           rmmod(module)
    
    CPU1:  ktask()
           ...
           ...
           __xnthread_test_cancel()
               do_exit()
                  (last) schedule()
    	         OOPS: prev still treading on stale memory
    
    In this case, the module would be unmapped too early, before the
    cancelled task can ultimately schedule away.
    
    The changes also fix a stale reference from the joiner thread to the
    former ->idtag field, after the joinee's TCB has been dropped.
    5902ea95