Subject: bug#40023: 26.3 Emacs crashes when creating process if many file handles are in use (e.g., when using ccls)

From: Robert Pluim <[email-masked]>
Date: Tue, 14 Apr 2020 18:14:19 +0200

>>>>> On Tue, 14 Apr 2020 18:02:47 +0200, Mattias Engdegård <[email-masked]> said:

    Mattias> 14 apr. 2020 kl. 15.58 skrev Robert Pluim <[email-masked]>:
    >> With lsp-mode I think itʼs one fd per directory containing a monitored
    >> file, but either way itʼs a limitation, and one that people are
    >> running into.

    Mattias> Are you sure? In contrast to inotify, kqueue can't detect changes to
    Mattias> the contents of files (or to their inodes) by monitoring their
    Mattias> containing directory.

C-x C-f my-dodgy-memory-disclaimer.txt :-)

    >> - the patch from
    >> <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=40023#32>, which
    >> reduces RLIMIT_NOFILE to FD_SETSIZE.

    Mattias> It's perhaps the least bad option for emacs-27. In addition to the
    Mattias> file monitoring requirement, there's the concern that the macOS libs
    Mattias> raise RLIMIT_NOFILE for reasons of their own, and that more things
    Mattias> will break when they no longer get what they want.

Libraries have no business messing with RLIMIT_NOFILE, but this is
macOS weʼre talking about.

    >> - select() -> poll(). GNU/Linux, macOS and *BSD all have poll, plus
    >> thereʼs a gnulib module for it that we could perhaps use on
    >> MS-Windows. As Eli says, not a small change.

    Mattias> Right. macOS doesn't have ppoll but Emacs doesn't seem to make any use of the sigmask argument.

Right, we always pass NULL.

Itʼs unfortunately very much a flag-day change that would need testing
on loads of different platforms. Or we #ifdef it to death.

Robert