Re: First thread in proc in not passed to thread_dtor eventhandler upon exit

From: Hans Petter Selasky <hps_at_selasky.org>
Date: Sun, 19 Feb 2017 09:43:24 +0100
On 02/19/17 04:54, Konstantin Belousov wrote:
> On Sat, Feb 18, 2017 at 10:40:00PM +0100, Hans Petter Selasky wrote:
>> Hi,
>>
>> Is the following a bug or feature. I observe that the first thread in a
>> procedure is not passed to thread_dtor as declared by the following
>> eventhandler, when the procedure exits.
>>
>> EVENTHANDLER_DECLARE(thread_dtor, thread_dtor_fn);
>>
>> Is this a bug or feature?
> This is a feature.  When a zombie process is reaped, the last thread in
> the process (the one which exited it) is left in the process thread list.
> This is an optimization, because process without at least one thread
> is never useful.
>
> You can see the code in fork1() which allocates struct proc from zone
> and then checks if there any thread pre-allocated as well (both struct
> proc and struct thread are type-stable).
>
> Since the last thread is not freed, its destructor is not signalled.

Hi Konstantin,

I see. To avoid leakage of LinuxKPI, Linux and Dtrace resources to all 
system threads, I think the attached patch is required. What do you 
think about the attached patch? If you don't like it can you suggest 
another approach?

--HPS

Received on Sun Feb 19 2017 - 07:44:08 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:10 UTC