Subject: bug#39164: 27.0.60; Intermittent crash on MacOS 10.14 in setup_process_coding_systems

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Thu, 30 Jan 2020 18:42:41 +0900

On Wed, 29 Jan 2020 21:38:32 +0900,
Eli Zaretskii wrote:
> 
> On January 29, 2020 1:09:16 PM GMT+02:00, Eli Zaretskii <[email-masked]> wrote:
> > On January 29, 2020 12:26:23 PM GMT+02:00, YAMAMOTO Mitsuharu
> > <[email-masked]> wrote:
> > > On Wed, 29 Jan 2020 02:37:10 +0900,
> > > Eli Zaretskii wrote:
> > > > 
> > > > > The increase happens only once per function in question.  So we
> > > make a
> > > > > dummy call in advance so later calls may not cause the increase
> > in
> > > > > unpredicable timings.
> > > > 
> > > > Can these dummy calls be made just before we call setrlimit in
> > > > init_process_emacs, as opposed to in a macOS-specific source file?
> > > 
> > > The functions in question are used together with Mac-specific GUI
> > > event handing.  I placed the dummy calls inside macOS-specific code
> > so
> > > the -nw case may not change the behavior from the original one.
> > 
> > We could condition the code in process.c by the aporopriate NS
> > preprocessor condition to make it take effect only in GUI sessions.
> 
> Sorry, preprocessor condition is not TRT, we should have a runtime test that limits these dummy calls to GUI sessions.
> 
> My point is that having this code in the same place for all platforms is better for long-range maintenance.

If we make dummy calls before setrlimit in init_process_emacs, then an
artificially increased limit is recorded to the variable nofile_limit,
and that will be used in restore_nofile_limit later.

				     YAMAMOTO Mitsuharu
				[email-masked]