bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#56002: src/process.c; make-process fails to clean up stderr process


From: Eli Zaretskii
Subject: bug#56002: src/process.c; make-process fails to clean up stderr process on early exit
Date: Thu, 11 Aug 2022 09:30:53 +0300

> From: Tom Gillespie <tgbugs@gmail.com>
> Date: Wed, 10 Aug 2022 19:33:22 -0700
> Cc: larsi@gnus.org, 56002@debbugs.gnu.org
> 
> So I realized that the current patch only fixes half the problems
> but it does fix them completely.
> 
> Your concerns are well founded but are only relevant to the half
> of the problems that this patch does not fix (more detail below).
> 
> Thus, this patch can be merged as is and a separate patch
> that uses unwind protect is needed to deal with failures that
> happen inside create_process. An additional test is needed
> for that as well since the current test only triggers a failure
> in Fmake_process prior to the call to create process.

I'd prefer to have all the cleanup in an unwind function, if that's
possible, because that would allow us not to rearrange the existing
code, and thus would be free of the potential risks I'm worried about.
We could have more than a single unwind function if that is required.

> Ideally the existing patches would be merged and I will submit
> another one with the fix for issues in create_process. The function
> used in unwind protectis going to be more complex and will need
> more review so we should not hold up the existing patch to wait
> for that one.

I'm not bothered with reviewing complex unwind functions, because
their code is local: we need to review that code without thinking
about anything that's not in it.

> > Maybe I'm misunderstand something here, but the usual way of doing
> > that is to use record_unwind_protect immediately after creating the
> > stderr process, with a suitable unwind function that would perform the
> > necessary cleanup.  This ensures that however we exit make-process,
> > the cleanup is never missed, and we don't leak resources.
> >
> > Why cannot we do this here?  What am I missing?
> 
> We could but do not need to for the issues inside Fmake_process
> since we can avoid writing any new code and move the call to
> Fmake_pipe_process to immediately before the call to create_process.

As I explained earlier, I'd prefer not to move the code we already
have.  Thus, basing the cleanups on unwind function is from my POV
preferable.

> There is no risk of unexpected interactions with os conventions
> prior to the call to create_process.

Opening file descriptors and creating Lisp objects in a different
sequence also affects the OS interactions, either indirectly or
directly.

> For any error happening in create_process before a successful return
> from emacs_spawn we do need to use record unwind protect. The
> function needed to do that cleanup safely is not as simple and
> should be in an independent patch that can be reviewed separately.

How about two separate patches, but both based on unwind function(s)
without moving any existing code?  You could make the unwind function
for the first patch simple, and then complicate it in the second
patch.

Thanks.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]