gregory-nutt commented on code in PR #15320:
URL: https://github.com/apache/nuttx/pull/15320#discussion_r1904131041


##########
libs/libc/stdio/lib_libvsprintf.c:
##########
@@ -163,6 +163,10 @@ static int vsprintf_internal(FAR struct lib_outstream_s 
*stream,
   uint16_t flags;
   int width;
   int prec;
+
+  /* For the %m format we may need the current `errno' value */
+
+  int saved_errno = errno;

Review Comment:
   > * in some context, accessing errno can crash. (eg. NULL dereference)
   
   TLS data of any kind cannot be accessed during initialization before the 
stack information is set up in the IDLE thread's TCB.  That TCB setup happens 
late in initialization.  If any attempt is made to access TLS, a null pointer 
dereference will occur and crash will follow.
   
   Even if the errno is not used, just referencing it in certain contexts will 
cause a crash.
   
   There is no TLS in the OS, so the errno access is still wrong after 
initialization but should not crash.
   
   I don't like that idea of leaving blatant errors and latent crashes in the 
OS.  That is not the way we develop a reliable OS that people can put their 
trust in.  The OS must be unbreakable.



-- 
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

Reply via email to