diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-02-25 19:08:52 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-02-26 09:23:02 +0100 |
commit | 1ac4a85ebf0cd0e788c2d5374c635087c33de0bf (patch) | |
tree | 55e5da6a482cc00eb616c6d01b9f2732900ab2b4 /cpukit/score/src/threadrestart.c | |
parent | libtest: Print SHA256 hash in base64url (diff) | |
download | rtems-1ac4a85ebf0cd0e788c2d5374c635087c33de0bf.tar.bz2 |
score: Fix thread initialization
Close the thread object if a thread create extension fails. Also call
the delete extension to avoid resource leaks in early extensions if a
late extension fails.
Close #4270.
Diffstat (limited to 'cpukit/score/src/threadrestart.c')
-rw-r--r-- | cpukit/score/src/threadrestart.c | 51 |
1 files changed, 4 insertions, 47 deletions
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c index cf92e25a5d..e56eaa9fc8 100644 --- a/cpukit/score/src/threadrestart.c +++ b/cpukit/score/src/threadrestart.c @@ -155,52 +155,6 @@ static void _Thread_Make_zombie( Thread_Control *the_thread ) _Thread_Wake_up_joining_threads( the_thread ); } -static void _Thread_Free( Thread_Control *the_thread ) -{ - Thread_Information *information; - - _User_extensions_Thread_delete( the_thread ); - _User_extensions_Destroy_iterators( the_thread ); - _ISR_lock_Destroy( &the_thread->Keys.Lock ); - _Scheduler_Node_destroy( - _Thread_Scheduler_get_home( the_thread ), - _Thread_Scheduler_get_home_node( the_thread ) - ); - _ISR_lock_Destroy( &the_thread->Timer.Lock ); - - /* - * The thread might have been FP. So deal with that. - */ -#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) -#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE ) - if ( _Thread_Is_allocated_fp( the_thread ) ) - _Thread_Deallocate_fp(); -#endif -#endif - - information = _Thread_Get_objects_information( the_thread ); - _Freechain_Push( - &information->Thread_queue_heads.Free, - the_thread->Wait.spare_heads - ); - - /* - * Free the rest of the memory associated with this task - * and set the associated pointers to NULL for safety. - */ - ( *the_thread->Start.stack_free )( the_thread->Start.Initial_stack.area ); - -#if defined(RTEMS_SMP) - _ISR_lock_Destroy( &the_thread->Scheduler.Lock ); - _ISR_lock_Destroy( &the_thread->Wait.Lock.Default ); - _SMP_lock_Stats_destroy( &the_thread->Potpourri_stats ); -#endif - - _Thread_queue_Destroy( &the_thread->Join_queue ); - _Context_Destroy( the_thread, &the_thread->Registers ); - _Objects_Free( &information->Objects, &the_thread->Object ); -} - static void _Thread_Wait_for_execution_stop( Thread_Control *the_thread ) { #if defined(RTEMS_SMP) @@ -227,10 +181,13 @@ void _Thread_Kill_zombies( void ) the_thread = (Thread_Control *) _Chain_Get_unprotected( &zombies->Chain ); while ( the_thread != NULL ) { + Thread_Information *information; + _ISR_lock_Release_and_ISR_enable( &zombies->Lock, &lock_context ); _Thread_Wait_for_execution_stop( the_thread ); - _Thread_Free( the_thread ); + information = _Thread_Get_objects_information( the_thread ); + _Thread_Free( information, the_thread ); _ISR_lock_ISR_disable_and_acquire( &zombies->Lock, &lock_context ); |