public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] hurd: Run init_pids () before init_dtable ()
@ 2023-04-17 21:04 Samuel Thibault
  0 siblings, 0 replies; only message in thread
From: Samuel Thibault @ 2023-04-17 21:04 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=346b6eab3c14ead0b716d53e2235464b822f48f2

commit 346b6eab3c14ead0b716d53e2235464b822f48f2
Author: Sergey Bugaev <bugaevc@gmail.com>
Date:   Sat Apr 15 22:08:56 2023 +0300

    hurd: Run init_pids () before init_dtable ()
    
    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 <bugaevc@gmail.com>

Diff:
---
 hurd/hurdinit.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/hurd/hurdinit.c b/hurd/hurdinit.c
index f88c566675..d0c7a83161 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-17 21:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-17 21:04 [glibc] hurd: Run init_pids () before init_dtable () Samuel Thibault

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).