GNU bug report logs - #54667
29.0.50; posix_spawn breaks emacs-gdb

Previous Next

Package: emacs;

Reported by: Herman, Géza <geza.herman <at> gmail.com>

Date: Fri, 1 Apr 2022 10:52:01 UTC

Severity: normal

Tags: fixed

Found in version 29.0.50

Fixed in version 29.1

Done: Robert Pluim <rpluim <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Philipp Stephani <p.stephani2 <at> gmail.com>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 54667 <at> debbugs.gnu.org, Géza <geza.herman <at> gmail.com>, Herman <at> debbugs.gnu.org
Subject: bug#54667: 29.0.50; posix_spawn breaks emacs-gdb
Date: Sun, 17 Apr 2022 20:53:26 +0200

> Am 01.04.2022 um 16:44 schrieb Robert Pluim <rpluim <at> gmail.com>:
> 
>>>>>> On Fri, 1 Apr 2022 15:29:50 +0200, "Herman, Géza" <geza.herman <at> gmail.com> said:
> 
>    Herman> I can confirm that it fixes the problem.
> 
> Thanks, Iʼll see if I can get around to committing it this weekend.
> 
>    Herman> For reference, here's the patch:
>    Herman> https://lists.gnu.org/archive/html/emacs-devel/2022-03/msg00067.html
> 
>    Herman> (Btw., according to this email thread, vfork is faster than
>    Herman> posix_spawn on Linux, so maybe it'd make sense to use posix_spawn only
>    Herman> on non-Linux platforms?)
> 
> In emacs-28 we only use posix_spawn on macOS because its vork is
> sub-optimal. I donʼt remember the rationale for switching to using it
> everywhere, itʼs undoubtedly in the archives somewhere.

My reasoning back then was:

1. Using fork/vfork has a few pitfalls (can't call async-signal-unsafe functions in the child process) that posix_spawn avoids (by not allowing arbitrary code between fork and exec).  Therefore, using posix_spawn is simpler and more obviously correct.
2. Because posix_spawn offers less functionality than fork+exec, it could be faster than the latter, e.g. by having it implemented in the kernel and avoiding page table copies.
3. Since we only run CI on GNU/Linux, it's useful to have only one codepath on all Unix-like systems so that issues that only appear on macOS are less likely to go unnoticed.

These arguments are still mostly correct, but there are some counterpoints:
1. We need to keep the fork/vfork code path anyway since posix_spawn doesn't allow us to correctly set up a pseudoterminal, so we still need to deal with the pitfalls.
2. posix_spawn is indeed much faster on macOS, but not so on GNU/Linux.  (I think it's unnecessarily slowed down on GNU/Linux by what I consider a bug in the POSIX standard.)
3. This is still true, but I'm not sure how much it matters given that the implementations of posix_spawn are completely different on GNU/Linux and macOS.



This bug report was last modified 3 years and 38 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.