[PATCH] D48451: [sanitizers_common] when spawning a subprocess for symbolizers, use posix_spawn instead of fork()

Alex Gaynor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 22 08:09:59 PDT 2018


alex added a comment.

In https://reviews.llvm.org/D48451#1140158, @eugenis wrote:

> Sorry I did not notice this before. Try vfork?


Simply using `vfork` instead of `fork` is probably a no-go: the `vfork`'s man page (on macOS, I haven't verified the panoply of other BSDs) says that `EINVAL` is returned when "A system call other than `_exit()` or `execve()` (or libc functions that make no system calls other than those) is called following calling a `vfork()` call." That is, on platforms with this constraint using `vfork` where we currently use `fork` will fail, because we use other syscalls to do things like setup the file descriptor table.

- One option would be to simply use `vfork` on Linux only (where it does not have this restriction), and `fork` on all other platforms; this probably has the smallest diff.
- Another option would be to use `posix_spawn` on every platform except Android older than P and retain the existing `fork`-based implementation for them; this has a larger diff, but maybe in some glorious future we can delete the fall-back implementation for Android and end up with less code. This also let's us avoid calling `vfork` directly, which I have confidence is safe here, but which nonetheless has relatively fiddly semantics.

Do you have a preference between these two?


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D48451





More information about the llvm-commits mailing list