Subject: bug#58960: closed (Re: bug#58960: 29.0.50; Assert fails when browsing an URL, bug#58960: 29.0.50; Assert fails when browsing an URL)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 02 Nov 2022 20:30:02 +0000

Your bug report

#58960: 29.0.50; Assert fails when browsing an URL

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
58960: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=58960
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#58960: 29.0.50; Assert fails when browsing an URL, bug#58960: 29.0.50; Assert fails when browsing an URL
From: Paul Eggert <[email-masked]>
To: Eli Zaretskii <[email-masked]>, Robert Pluim <[email-masked]>
Cc: [email-masked], [email-masked], [email-masked]
Date: Wed, 2 Nov 2022 13:29:39 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

On 11/2/22 08:09, Eli Zaretskii wrote:
>> Why canʼt we just call `child_signal_init' from `init_process_emacs'
>> instead of `create_process'?
> Maybe we could.  Assuming the signal stuff is already set so early, I
> don't know exactly how posix_spawn works.

child_signal_init is reasonably heavyweight in that it keeps a couple of 
file descriptors open, so the idea is to be lazy and not call it unless 
Emacs plans to have children.

I installed the attached, which is like Robert's patch except it keeps 
the critical section smaller and checks the declaration of the 
now-extern function. Please give it a try. I'll boldly close the bug 
report; we can reopen it if I'm wrong.

From 05f5d978ae70c4849a5c47865d62301d27317a8a Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Wed, 2 Nov 2022 13:24:26 -0700
Subject: [PATCH] Initialize child signal handling before posix_spawn too.

Problem reported by Tino Calancha (Bug#58960).
* src/callproc.c (call_process): Initialize SIGCHLD handling
before possibly creating a child with emacs_span.  This need not
be in the critical section that calls emacs_spawn, so do it
outside the critical section.
* src/process.c (child_signal_init): Now extern.
---
 src/callproc.c | 1 +
 src/lisp.h     | 1 +
 src/process.c  | 3 +--
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/callproc.c b/src/callproc.c
index 4d4b86629c..f9f840e544 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -648,6 +648,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
 
 #ifndef MSDOS
 
+  child_signal_init ();
   block_input ();
   block_child_signal (&oldset);
 
diff --git a/src/lisp.h b/src/lisp.h
index d87f954938..eafa241adf 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4915,6 +4915,7 @@ #define DAEMON_RUNNING (w32_daemon_event != INVALID_HANDLE_VALUE)
 
 /* Defined in process.c.  */
 struct Lisp_Process;
+extern void child_signal_init (void);
 extern void kill_buffer_processes (Lisp_Object);
 extern int wait_reading_process_output (intmax_t, int, int, bool, Lisp_Object,
 					struct Lisp_Process *, int);
diff --git a/src/process.c b/src/process.c
index 358899cded..5144c5d6c9 100644
--- a/src/process.c
+++ b/src/process.c
@@ -292,7 +292,6 @@ 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);
 #ifndef WINDOWSNT
 static void child_signal_read (int, void *);
 #endif
@@ -7323,7 +7322,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.  */
-- 
2.38.1

Subject: 29.0.50; Assert fails when browsing an URL
From: Tino Calancha <[email-masked]>
To: [email-masked]
Date: Wed, 2 Nov 2022 05:48:30 +0100 (CET)
List-Id: <debbugs-submit.debbugs.gnu.org>

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

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

process.c:7386: Emacs fatal error: assertion failed: 0 <= fd
Fatal error 6: Aborted
Backtrace:
emacs[0x610be3]
emacs[0x5d806c]
emacs[0x68a1a0]
emacs[0x73b497]
emacs[0x73b900]
emacs[0x6103ae]
emacs[0x73b92b]
/lib64/libpthread.so.0(+0x12ce0)[0x7f937e22ace0]
emacs[0x669b85]
emacs[0x669bf0]
emacs[0x675dd7]
emacs[0x673dfc]
emacs[0x6736f3]
emacs[0x661f1f]
emacs[0x63996b]
emacs[0x63ac19]
emacs[0x6c5492]
emacs[0x7236f7]
emacs[0x6c578c]
emacs[0x6c5be4]
emacs[0x6c4f15]
emacs[0x6c520c]
emacs[0x6c406f]
emacs[0x6c5629]
emacs[0x7236f7]
emacs[0x6c578c]
emacs[0x6c5be4]
emacs[0x6c4f15]
emacs[0x6c520c]
emacs[0x5dd79a]
emacs[0x5ea9e8]
emacs[0x5eab38]
emacs[0x5e7b76]
emacs[0x5f1d97]
emacs[0x5fb14e]
emacs[0x5e486a]
emacs[0x5f9229]
emacs[0x5e090f]
emacs[0x6c0a85]
emacs[0x5e0110]
emacs[0x6bfd21]
emacs[0x5e00a8]
emacs[0x5df4a5]
emacs[0x5df6ad]
emacs[0x5db103]
/lib64/libc.so.6(__libc_start_main+0xf3)[0x7f937d057cf3]
emacs[0x4180ce]

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
  version 1.15.12, Xaw scroll bars) of 2022-11-02 built on
  tcalanch.remote.csb
Repository revision: 8a5678906fa1b899c4d111e5ee4334b278f50d48
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Red Hat Enterprise Linux 8.6 (Ootpa)

Configured using:
  'configure --enable-checking=yes,glyphs --enable-check-lisp-object-type
  --with-x-toolkit=lucid 'CFLAGS=-O0 -g3' --with-gif=ifavailable'

Configured features:
ACL CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG
LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND
THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XINPUT2 XPM LUCID ZLIB

Important settings:
   value of $LANG: en_US.UTF-8
   value of $XMODIFIERS: @im=ibus
   locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
   tooltip-mode: t
   global-eldoc-mode: t
   eldoc-mode: t
   show-paren-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   line-number-mode: t
   indent-tabs-mode: t
   transient-mark-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date subr-x mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils rmc iso-transl tooltip cconv eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
xinput2 x multi-tty make-network-process emacs)

Memory information:
((conses 16 36693 5402)
  (symbols 48 5093 0)
  (strings 32 13962 1228)
  (string-bytes 1 383102)
  (vectors 16 9295)
  (vector-slots 8 147845 11034)
  (floats 8 34 25)
  (intervals 56 239 0)
  (buffers 984 10))