Subject: bug#24325: 25.1; Crash - fd larger than FD_SETSIZE

From: Robin Campbell Joy <[email-masked]>
Date: Sun, 28 Aug 2016 22:44:21 +0200

> On 28 August 2016 at 19:53, Eli Zaretskii <[email-masked]> wrote:
>
> > From: Robin Campbell Joy <[email-masked]>
> > Date: Sun, 28 Aug 2016 11:25:39 +0200
> >
> > After a short time emacs is crashing while trying to communicate with an
> > external process.
> >
> > In the debugger I can see that the fd is larger than FD_SETSIZE. The fd
> > is used in process.c:7168-7177 (setup_process_coding_system) to index
> > into proc_decode_coding_system which is of size FD_SETSIZE and is
> > crashing at process.c:5708 when dereferencing coding->id.
>
> Do you really have several hundreds of subprocesses and/or network
> connections active in that session?  If not, how come all the
> descriptors below 1024 are in use?

This seems to be a bug in rtags.el or my configuration or a combination of
both.
 It is calling start-file-process several hundred times. Not sure yet why.

>
> I also don't understand how this:
>
> > #0 0x00000000004942a4 in setup_coding_system (coding_system=4602512,
coding=0xffffffffffffffff) at
> > coding.c:5706
> > eol_type = <optimized out>
>           ^^^^^^^^^^^^
> Can happen in a build that claims to use 'CFLAGS=-ggdb3 -O0'.  Did you
> report the bug from the same binary that crashes?
>
> I guess we will have to refuse to handle a process if its infd and
> outfd are at or above FD_SETSIZE, like we do on MS-Windows?

sorry, I also tried to reproduce it with a non-optimized build to see if I
can see more in the debugger, however I just ran into memory corruption
which lead to all kinds of erratic behaviour but not to a crash. I used the
non-optimized one to generate the bug report as the optimized one is
crashing shortly after startup. I thought I removed the additional CFLAGS
but seems like I missed at least one. The rest of the build flags should be
correct, just without 'CFLAGS=-ggdb3 -O0'