Possible deadlock in localtime_r after fork in multithreaded process

Cristian Rodriguez yo@cristianrodriguez.net
Fri Jun 5 15:21:40 GMT 2026


On Fri, Jun 5, 2026 at 6:21 AM Cuishuangjin <YS.cuishuangjin@h3c.com> wrote:

>         if (pid == 0) {
>
>             time(&t);
>
>             localtime_r(&t, &tm_info);


There.
  stop.
 you are done.

Have entered into UB territory

" • After a fork() in a multithreaded program, the child can safely
          call only async-signal-safe functions (see signal-safety(7))
          until such time as it calls execve(2)."
not saying it has to be this way, Im telling you what you should
expect to happen.


More information about the Libc-alpha mailing list