unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Tom Gillespie <tgbugs@gmail.com>
Cc: larsi@gnus.org, 56002@debbugs.gnu.org
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	[thread overview]
Message-ID: <83v8qzpa02.fsf@gnu.org> (raw)
In-Reply-To: <CA+G3_PO2g-xK=X2bF0UuAC=OP0idko1TDvvztSYQfEQqqFdq-Q@mail.gmail.com> (message from Tom Gillespie on Wed, 10 Aug 2022 19:33:22 -0700)

> 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	other threads:[~2022-08-11  6:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-15 22:38 bug#56002: src/process.c; make-process fails to clean up stderr process on early exit Tom Gillespie
2022-06-16  2:28 ` bug#56002: update with an additional example Tom Gillespie
2022-06-16  5:13 ` bug#56002: src/process.c; make-process fails to clean up stderr process on early exit Eli Zaretskii
2022-06-16  6:11   ` Tom Gillespie
2022-06-29 21:17     ` Tom Gillespie
2022-08-07 23:48       ` Tom Gillespie
2022-08-08 11:36         ` Lars Ingebrigtsen
2022-08-08 11:57           ` Eli Zaretskii
2022-08-08 18:54             ` Tom Gillespie
2022-08-09 11:43               ` Eli Zaretskii
2022-08-09 18:59                 ` Tom Gillespie
2022-08-10 18:06                   ` Eli Zaretskii
2022-08-11  2:33                     ` Tom Gillespie
2022-08-11  6:30                       ` Eli Zaretskii [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83v8qzpa02.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=56002@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=tgbugs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).