pussuw commented on PR #6197: URL: https://github.com/apache/incubator-nuttx/pull/6197#issuecomment-1134923458
> I amn't sure why you get crash here since the code exist for a long time. Yes, it isn't good to flush the stdio stream inside kernel, but it should work not crash at least. Call _exit() directly and it will crash. It is due to bad execution order. nxtask_exit() calls 1. nxsched_remove_readytorun(dtcb); 2. ret = nxtask_terminate(dtcb->pid, true); 3. nxtask_exithook(dtcb, EXIT_SUCCESS, nonblocking); Anything inside `nxtask_exithook()` that depends on `this_task()` fails. Eventually it ends up into `int nxsem_wait(FAR sem_t *sem) `where there is a test for the calling task `DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask());` I don't remember which semaphore it was but calling ` _exit()` directly crashes the system for sure, either via that assert or by modifying something by calling `this_task()` and using what is returned. -- 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. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org