patacongo edited a comment on issue #1263:
URL: 
https://github.com/apache/incubator-nuttx/issues/1263#issuecomment-846405029


   #3626 has been merged.  This resolves security issues associated with 
pthreads.  the comments were abstracted from #3626 
   
   @no1wudi Are you interested in finishing this job?  That is, fixing 
on_exit() and atexit() callbacks so that they execute in user mode in all build 
modes?  Logically this would be a very similar job:  task_startup() and task 
exits would have to be moved to libs/libc and the callbacks would have to be 
re-architected so that the call back function points and parameters lie in TLS 
and the functions are called in some user-space task exit logic.
   
   This, however, is more complex for several reasons:
   
   1. Aspecial case, however, are kernel threads.  Currently, they can also 
have on_exit() and atexit() callbacks -- but unlike tasks, these must run in 
supervisor mode.
   2. on_exit() and atexit() processing is more entangled task_exithook().  
However, I think that that entanglement is no longer necessary.  I think it is 
an artifact from an older design.  It should be okay to move those callbacks to 
the beginning of the exit sequence in the current design.  Hmm.. is there some 
reason why the exit callbacks should not execute while there could be pthreads 
running in an SMP configuration?  There are a few things to think about.
   3. The task_startup() function is the same for the FLAT and PROTECTED 
builds, but works differently in the KERNEL build.   In that case, a crt0.o 
file it linked at the beginning of th problem.  See for example: 
https://github.com/apache/incubator-nuttx/blob/master/arch/arm/src/armv7-a/crt0.c
   4. There are several ways that a task can exit: exit(), task_delete(), 
task_reset(), assert(), abort(), .... others?
   
   _exit() might also be in that group, but since that is reserved for 
emergency terminations, it probably does not need to honor the on_exit() / 
atexit() (In fact, it is not really safe to call _exit() at all in an embedded 
system since it leaves files open).
   
   There is a block diagram of the exit sequence here:  
https://cwiki.apache.org/confluence/display/NUTTX/Task+Exit+Sequence  I am not 
sure if that is 100% up to date.
   
   Related #3333 #1265 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to