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

From: Eli Zaretskii <[email-masked]>
Date: Wed, 02 Nov 2022 17:09:45 +0200

> From: Robert Pluim <[email-masked]>
> Cc: Paul Eggert <[email-masked]>,  [email-masked],
>   [email-masked],  [email-masked]
> Date: Wed, 02 Nov 2022 14:58:23 +0100
> 
> >>>>> On Wed, 02 Nov 2022 15:10:07 +0200, Eli Zaretskii <[email-masked]> said:
> 
>     >> Cc: Gerd Möllmann <[email-masked]>,
>     >> [email-masked]
>     >> From: Robert Pluim <[email-masked]>
>     >> Date: Wed, 02 Nov 2022 11:20:31 +0100
>     >> 
>     >> Looks like `call-process' needs to ensure the child signal fdʼs are
>     >> set up before calling `emacs_spawn'.
> 
>     Eli> Why do we need this?  IOW, do you understand how did SIGCHLD cause
>     Eli> this?
> 
> `browse-url' does `call-process' for `xdg-open' by default. `xdg-open'
> exits almost immediately, we get SIGCHLD:

Ugh, xdg-open again...

> (gdb) bt
> #0  terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:421
> #1  0x00005555555b489e in die
>     (msg=msg@entry=0x5555558d938f "0 <= fd", file=file@entry=0x5555558d9354 "process.c", line=line@entry=7386) at alloc.c:7692
> #2  0x00005555555bfec9 in child_signal_notify () at process.c:7386
> #3  handle_child_signal (sig=<optimized out>) at process.c:7493
> #4  0x000055555574e992 in deliver_process_signal
>     (sig=17, handler=0x555555831b40 <handle_child_signal>) at sysdep.c:1741
> #5  0x00007ffff5752140 in <signal handler called> ()
> 
> `child_signal_notify' does this:
> 
>   int fd = child_signal_write_fd;
>   eassert (0 <= fd);
> 
> and if `child_signal_init' hasnʼt been called, then this is still
> true:
> 
> /* The write end thereof.  The SIGCHLD handler writes to this file
>    descriptor to notify `wait_reading_process_output' of process
>    status changes.  */
> static int child_signal_write_fd = -1;
> 
> so the assert fails.
> 
> 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.

Paul, WDYT about this?