Date: Fri, 3 Apr 2020 11:28:54 +0200 From: Szabolcs Nagy <nsz@...t70.net> To: musl@...ts.openwall.com Cc: "zhangwentao (M)" <zhangwentao234@...wei.com> Subject: Re: doubt about fork * guolongqiang <guolongqiang@...wei.com> [2020-04-03 06:37:44 +0000]: > Hello, > I have a problem about multi threads fork. The implement of fork not lock such as stdio file, > __thread_list_lock, or other global mutexs in musl libc before syscall of SYS_clone, this will > cause dead lock in child. Is this a bug? the standard is pretty clear that the child after fork in a multi-threaded process can only do async-signal-safe operations, anything that may lock is not as-safe. https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html incidentally glibc tries to make certain operations work in the child by taking libc internal locks before fork and releasing them after, however that does not give strong guarantees of stdio use in the child because glibc supports malloc interposition and the interposed malloc can't reliably handle fork (i.e locks may be held in the child) so stdio (and all libc apis that may internally allocate) can still deadlock i.e. you don't get more guarantees on other implementations either than the standard. > > Hope your response! > --Guo Longqiang
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.