Subject: bug#58960: 29.0.50; Assert fails when browsing an URL, bug#58960: 29.0.50; Assert fails when browsing an URL

From: Robert Pluim <[email-masked]>
Date: Wed, 02 Nov 2022 11:20:31 +0100

>>>>> On Wed, 2 Nov 2022 05:48:30 +0100 (CET), Tino Calancha <[email-masked]> said:

    Tino> emacs -Q
    Tino> M-x browse-url RET
    Tino> https://www.example.com RET

    Tino> [The URL is opened by my default browser and Emacs crashes with the
    Tino> following backtrace]

    Tino> process.c:7386: Emacs fatal error: assertion failed: 0 <= fd

This goes away if you do something like 'M-x shell' first, right?

Looks like `call-process' needs to ensure the child signal fdʼs are
set up before calling `emacs_spawn'. Iʼm suprised nobody has run into
this before. Does the (dirty) patch below fix things for you?

Robert
-- 

diff --git i/src/process.c w/src/process.c
index 358899cded..4690addcf1 100644
--- i/src/process.c
+++ w/src/process.c
@@ -292,7 +292,7 @@ network_lookup_address_info_1 (Lisp_Object host, const char *service,
    descriptor to notify `wait_reading_process_output' of process
    status changes.  */
 static int child_signal_write_fd = -1;
-static void child_signal_init (void);
+void child_signal_init (void);
 #ifndef WINDOWSNT
 static void child_signal_read (int, void *);
 #endif
@@ -7323,7 +7323,7 @@ DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0,
 
 /* Set up `child_signal_read_fd' and `child_signal_write_fd'.  */
 
-static void
+void
 child_signal_init (void)
 {
   /* Either both are initialized, or both are uninitialized.  */
diff --git i/src/callproc.c w/src/callproc.c
index 4d4b86629c..10ec643861 100644
--- i/src/callproc.c
+++ w/src/callproc.c
@@ -328,7 +328,7 @@ DEFUN ("call-process", Fcall_process, Scall_process, 1, MANY, 0,
    this case NARGS must be at least 2 and ARGS[1] is the file's name.
 
    At entry, the specpdl stack top entry must be close_file_unwind (FILEFD).  */
-
+extern void child_signal_init (void);
 static Lisp_Object
 call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
 	      specpdl_ref tempfile_index)
@@ -650,7 +650,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
 
   block_input ();
   block_child_signal (&oldset);
-
+  child_signal_init ();
   child_errno
     = emacs_spawn (&pid, filefd, fd_output, fd_error, new_argv, env,
                    SSDATA (current_dir), NULL, false, false, &oldset);