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: Tue, 09 Aug 2022 14:43:04 +0300	[thread overview]
Message-ID: <83czd9ve0n.fsf@gnu.org> (raw)
In-Reply-To: <CA+G3_POmUnEozARB4WhLsM5esYOyQPKAKwPD7XxyZLRVWAZPCg@mail.gmail.com> (message from Tom Gillespie on Mon, 8 Aug 2022 11:54:09 -0700)

> From: Tom Gillespie <tgbugs@gmail.com>
> Date: Mon, 8 Aug 2022 11:54:09 -0700
> Cc: Lars Ingebrigtsen <larsi@gnus.org>, 56002@debbugs.gnu.org
> 
> > TBH, I don't understand the rationale well enough.  What does it mean
> > we "leak stderr process"? isn't the stderr process recycled if
> > make-process fails?
> 
> When the stderrproc is created internally there is no way that it can be
> reused because nothing else has a reference to it. The changes here only
> deal with cases where a stderrproc is not provided by the caller.

This is a misunderstanding: I meant "recycled" as in
"garbage-collected".  GC in Emacs is supposed to prevent leaks of
memory and resources.  You seem to be saying that this somehow doesn't
work in this case.  Can you explain why it doesn't work, and which
resources specifically appear to be leaking?

> > Is it just a matter of some simple change in the
> > control flow, to make sure we always go through the cleanup code
> > before we return?
> 
> There is no way easy way to modify the control flow because there are
> so many possible points where process creation can fail unexpectedly
> that must be handled if the stderrproc is created too early.

But we have code that errors out in the middle of processing all over
the place, and that is safe in Emacs, because any unused Lisp objects
will be GC'ed soon.  Why is this case special?

> It is very hard to determine exactly which statements inside of make
> process can produce unexpected exits, I have encountered at least
> two, but I'm sure there are others. Thus the safest thing to do was to
> move creation of stderrproc after all the points where process creation
> can potentially fail (e.g. failures during vfork).
> 
> > In general, I'd prefer not to change timing of what we do in
> > make-process unless it's really unavoidable.  There's a lot of
> > system-dependent stuff there, and who knows what will that cause on
> > some platform?
> 
> I'm fairly certain that it is impossible for there to be any interaction between
> the primary process and the stderr proc at any point in time prior to where
> I moved the creation of the stderrproc because the first reference to
> p->stderrproc after it is created is in create_process.

I meant the potential interactions that are not explicitly visible by
reading the code, but instead stem from system-dependent stuff that is
related to how subprocesses are created on different systems.

So I'd still be happier if we could deal with the problem without
moving chunks of code around.

Thanks.





  reply	other threads:[~2022-08-09 11:43 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 [this message]
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

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=83czd9ve0n.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).