all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dan Nicolaescu <dann@ics.uci.edu>
To: emacs-devel@gnu.org
Subject: Re: leak in make-network-process
Date: Mon, 29 Dec 2008 11:10:14 -0800 (PST)	[thread overview]
Message-ID: <200812291910.mBTJAEUT027466@mothra.ics.uci.edu> (raw)
In-Reply-To: <200812221802.mBMI28aU001131@mothra.ics.uci.edu> (Dan Nicolaescu's message of "Mon, 22 Dec 2008 10:02:08 -0800 (PST)")

Dan Nicolaescu <dann@ics.uci.edu> writes:

  > Do 
  > 
  > emacs -Q --daemon
  > (to make sure there's a  server running)
  > 
  > then 
  > 
  > emacs -Q -l test.el 
  > 
  > 
  > cat test.el
  > 
  > (defun gc-output (arg)
  >   (interactive "M")
  >   (with-current-buffer "*scratch*"
  >     (insert (format "%s %S\n" arg
  > 		    (garbage-collect)))))
  > 
  > (defun server-running-p (&optional name)
  >   "Test whether server NAME is running.
  > 
  > Return values:
  >   nil              the server is definitely not running.
  >   t                the server seems to be running.
  >   something else   we cannot determine whether it's running without using
  >                    commands which may have to wait for a long time."
  >   (interactive
  >    (list (if current-prefix-arg
  > 	     (read-string "Server name: " nil nil server-name))))
  >   (unless name (setq name server-name))
  >   (condition-case nil
  >       (if server-use-tcp
  > 	  (with-temp-buffer
  > 	    (insert-file-contents-literally (expand-file-name name server-auth-dir))
  > 	    (or (and (looking-at "127\.0\.0\.1:[0-9]+ \\([0-9]+\\)")
  > 		     (assq 'comm
  > 			   (system-process-attributes
  > 			    (string-to-number (match-string 1))))
  > 		     t)
  > 		:other))
  > 	(gc-output "B make-net")
  > 	(delete-process
  > 	 (make-network-process
  > 	  :name "server-client-test" :family 'local :server nil :noquery t
  > 	  :service (expand-file-name name server-socket-dir)))
  > 	(gc-output "A make-net")
  > 	t)
  >     (file-error nil)))
  > 
  > 
  > Now do
  > M-x server-start RET
  > 
  > it won't start a server, but in the it will print in the *scratch*
  > buffer the GC results before and after the `(delete-process (make-network-process ' call.
  > There's a leak of 22 conses.
  > 
  > Adding this at the end of process.c:remove_process:
  > 
  >   {
  >     struct Lisp_Process *p = XPROCESS (proc);
  >     /* Set all Lisp_Object members of struct Lisp_Process to nil.  */
  >     p->tty_name = Qnil;
  >     p->name = Qnil;
  >     p->command = Qnil;
  >     p->filter = Qnil;
  >     p->sentinel = Qnil;
  >     p->log = Qnil;
  >     p->buffer = Qnil;
  >     p->childp = Qnil;
  >     p->plist = Qnil;
  >     p->type = Qnil;
  >     p->mark = Qnil;
  >     p->status = Qnil;
  >     p->decode_coding_system = Qnil;
  >     p->decoding_buf = Qnil;
  >     p->encode_coding_system = Qnil;
  >     p->encoding_buf = Qnil;
  >   }
  > 
  > reduces the leak to 4 conses.  Not sure if doing that is TRTD...

Actually only this is needed:

  {
    struct Lisp_Process *p = XPROCESS (proc);
    /* Set all Lisp_Object members of struct Lisp_Process to nil.  */
    p->childp = Qnil;
    p->status = Qnil;
  }


p->childp is a plist in the case of network processes
p->status is set to a cons by Fdelete_process for network processes

Why can't GC get these fields?  Should something like this be checked
in?




  reply	other threads:[~2008-12-29 19:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-22 18:02 leak in make-network-process Dan Nicolaescu
2008-12-29 19:10 ` Dan Nicolaescu [this message]
2008-12-30  2:14   ` Chong Yidong
2008-12-30 21:18     ` Stefan Monnier

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

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

  git send-email \
    --in-reply-to=200812291910.mBTJAEUT027466@mothra.ics.uci.edu \
    --to=dann@ics.uci.edu \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.