From owner-freebsd-current@freebsd.org Sun Feb 19 03:54:29 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8147FCE53FF for ; Sun, 19 Feb 2017 03:54:29 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E36AAF70 for ; Sun, 19 Feb 2017 03:54:28 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v1J3sNuU022148 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 19 Feb 2017 05:54:23 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v1J3sNuU022148 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v1J3sMgT022147; Sun, 19 Feb 2017 05:54:23 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 19 Feb 2017 05:54:22 +0200 From: Konstantin Belousov To: Hans Petter Selasky Cc: FreeBSD Current Subject: Re: First thread in proc in not passed to thread_dtor eventhandler upon exit Message-ID: <20170219035422.GQ2092@kib.kiev.ua> References: <933e132d-289b-330d-b349-584a25e279d4@selasky.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <933e132d-289b-330d-b349-584a25e279d4@selasky.org> User-Agent: Mutt/1.7.2 (2016-11-26) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Feb 2017 03:54:29 -0000 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. > > I see a couple of clients in the kernel and if the first thread in proc > is simply recycled by re-init, we're leaking data for these clients? > And I'm planning to add one more for the LinuxKPI. > > Any insight? > > --HPS > _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"