qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/5] linux-user: Support CLONE_VM and extended clone options


From: Josh Kunz
Subject: Re: [PATCH 4/5] linux-user: Support CLONE_VM and extended clone options
Date: Fri, 12 Jun 2020 17:10:29 -0700

> +    child_tid = atomic_fetch_or(&mgr->managed_tid, 0);
> +    /*
> +     * Check if the child has already terminated by this point. If not, wait
> +     * for the child to exit. As long as the trampoline is not killed by
> +     * a signal, the kernel guarantees that the memory at &mgr->managed_tid
> +     * will be cleared, and a FUTEX_WAKE at that address will triggered.
> +     */
> +    if (child_tid != 0) {
> +        ret = syscall(SYS_futex, &mgr->managed_tid, FUTEX_WAIT,
> +                      child_tid, NULL, NULL, 0);
> +        assert(ret == 0 && "clone manager futex should always succeed");
> +    }

A note for any reviewers/maintainers: While doing some additional
testing today, I discovered there is a bug in this section of the
patch. The child process can exit between the `atomic_fetch` and start
of the `futex(FUTEX_WAIT)` call, causing the kernel to respond with an
`EAGAIN` error, which will be caught by the assert and crash the
program. I have a patch for this. I suspect there will be comments on
this change, so I'm holding off on re-sending the series until initial
reviews have been done. I just wanted to make maintainers aware to
avoid the possibility of this bug being merged in the (very) unlikely
case there are no comments.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]