From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 9673F3858D28 for ; Mon, 17 Apr 2023 21:05:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9673F3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1poW2H-0000Up-9C; Mon, 17 Apr 2023 17:05:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=In-Reply-To:MIME-Version:References:Subject:To:From: Date; bh=fLPwf7tAz6WCarWJtqnRJ1Sbav1ggbBWPeyoStC5ems=; b=CEPnSBUdr48dOiqUMJH7 ev0ZplQad9pV7VmtBd9DJD6kzO5pJ32GjJd7tnkChKow0tGq75OkNCQB6qUrNbLDSVIGTIvI7LmBo swP4vTdW/14mJ0M9ICAd5sy4XEQdxbhqvUpTJu1gfKgqv2KgkN1m6mJO0agQkPjescH7MNWokPK0q gV0QRUz89EMPcASHyp7d+vW0aQ433BTP74gNdEzFBYP1pc/UJyhCoBPnt62FrAObGIkBY0knTkSYI FRqve3WX9C86nxERcx5Zu6X3Sdb+SqCcQadtEfZXozQe7EFJMrj8knRu3T2sa/IzrZIox3H8qbd+Y QuEfAhmVK+kByQ==; Received: from 2a01cb008c251f00de41a9fffe47ec49.ipv6.abo.wanadoo.fr ([2a01:cb00:8c25:1f00:de41:a9ff:fe47:ec49] helo=begin.home) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1poW2H-0002an-24; Mon, 17 Apr 2023 17:05:17 -0400 Received: from samy by begin.home with local (Exim 4.96) (envelope-from ) id 1poW2E-005i1I-27; Mon, 17 Apr 2023 23:05:14 +0200 Date: Mon, 17 Apr 2023 23:05:14 +0200 From: Samuel Thibault To: Sergey Bugaev Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: Re: [PATCH] hurd: Run init_pids () before init_dtable () Message-ID: <20230417210514.3sgkgkfr64rezaiz@begin> Mail-Followup-To: Sergey Bugaev , libc-alpha@sourceware.org, bug-hurd@gnu.org References: <20230415175826.at5pjnu2wp54vlhv@begin> <20230415190856.109348-1-bugaevc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230415190856.109348-1-bugaevc@gmail.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Applied, thanks! Sergey Bugaev, le sam. 15 avril 2023 22:08:56 +0300, a ecrit: > Much as the comment says, things on _hurd_subinit assume that _hurd_pid > is already initialized by the time _hurd_subinit is run, so > _hurd_proc_subinit has to run before it. Specifically, init_dtable () > calls _hurd_port2fd (), which uses _hurd_pid and _hurd_pgrp to set up > ctty handling. With _hurd_subinit running before _hurd_proc_subinit, > ctty setup was broken: > > 13<--33(pid1255)->term_getctty () = 0 4<--39(pid1255) > task16(pid1255)->mach_port_deallocate (pn{ 10}) = 0 > 13<--33(pid1255)->term_open_ctty (0 0) = 0x40000016 (Invalid argument) > > Fix this by running the _hurd_proc_subinit hook in the correct place -- > just after _hurd_portarray is set up (so the proc server port is > available in its usual place) and just before running _hurd_subinit. > > Fixes 1ccbb9258eed0f667edf459a28ba23a805549b36 > ("hurd: Notify the proc server later during initialization"). > > Signed-off-by: Sergey Bugaev > --- > hurd/hurdinit.c | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/hurd/hurdinit.c b/hurd/hurdinit.c > index f88c5666..d0c7a831 100644 > --- a/hurd/hurdinit.c > +++ b/hurd/hurdinit.c > @@ -54,6 +54,10 @@ _hurd_ports_use (int which, error_t (*operate) (mach_port_t)) > > DEFINE_HOOK (_hurd_subinit, (void)); > > +/* Hook for things which should be initialized as soon as the proc > + server is available. */ > +DEFINE_HOOK (_hurd_proc_subinit, (void)); > + > __typeof (_hurd_proc_init) _hurd_new_proc_init; /* below */ > > /* Initialize the library data structures from the > @@ -105,6 +109,11 @@ _hurd_init (int flags, char **argv, > */ > } > > + /* Call other things which want to do some initialization. These are not > + on the _hurd_subinit hook because things there assume that things done > + here, like _hurd_pid, are already initialized. */ > + RUN_RELHOOK (_hurd_proc_subinit, ()); > + > /* Call other things which want to do some initialization. These are not > on the __libc_subinit hook because things there like to be able to > assume the availability of the POSIX.1 services we provide. */ > @@ -148,10 +157,6 @@ libc_hidden_def (_hurd_libc_proc_init) > sure the arguments are never visible with `ps'. */ > int _hide_arguments, _hide_environment; > > -/* Hook for things which should be initialized as soon as the proc > - server is available. */ > -DEFINE_HOOK (_hurd_proc_subinit, (void)); > - > /* Do startup handshaking with the proc server just installed in _hurd_ports. > Call _hurdsig_init to set up signal processing. */ > > @@ -187,11 +192,6 @@ _hurd_new_proc_init (char **argv, > /* Initialize proc server-assisted fault recovery for the signal thread. */ > _hurdsig_fault_init (); > > - /* Call other things which want to do some initialization. These are not > - on the _hurd_subinit hook because things there assume that things done > - here, like _hurd_pid, are already initialized. */ > - RUN_RELHOOK (_hurd_proc_subinit, ()); > - > /* XXX This code should probably be removed entirely at some point. This > conditional should make it reasonably usable with old gdb's for a > while. Eventually it probably makes most sense for the exec server to > -- > 2.39.2 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.