Re: [PATCH v2] kernel/exit: do panic earlier to get coredump if global init task exit

From: Oleg Nesterov
Date: Tue Dec 17 2019 - 09:15:00 EST


On 12/16, Christian Brauner wrote:
>
> On Mon, Dec 16, 2019 at 06:28:41PM +0100, Oleg Nesterov wrote:
> >
> > And I am worried atomic_dec_and_test() is called too early...
> >
> > Say, acct_process() can report the exit while some sub-thread sleeps
>
> Hm, I'm not following here. I might just be slow. acct_process() doesn't
> seem to report exit status and has been called after group_dead before.

Yes, but with this patch group_dead becomes true before the process is
"dead enough".

Suppose a process has 2 threads, T1, and T2.

T1 exits, decrements signal->live, and sleeps in PTRACE_EVENT_EXIT.

T2 exits, decrements signal->live, group_dead == T, it calls acct_process()
which reports the fact this process has exited. Probably not a real problem,
but still strange, this process has not exited yet, it is not even a zombie.

Oleg.