From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: Re: leak in make-network-process Date: Mon, 29 Dec 2008 11:10:14 -0800 (PST) Message-ID: <200812291910.mBTJAEUT027466@mothra.ics.uci.edu> References: <200812221802.mBMI28aU001131@mothra.ics.uci.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1230577845 4979 80.91.229.12 (29 Dec 2008 19:10:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 29 Dec 2008 19:10:45 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 29 20:11:51 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LHNWl-0000jC-8h for ged-emacs-devel@m.gmane.org; Mon, 29 Dec 2008 20:11:47 +0100 Original-Received: from localhost ([127.0.0.1]:50816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LHNVX-0005xt-LN for ged-emacs-devel@m.gmane.org; Mon, 29 Dec 2008 14:10:31 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LHNVP-0005vs-Ng for emacs-devel@gnu.org; Mon, 29 Dec 2008 14:10:23 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LHNVO-0005vU-S5 for emacs-devel@gnu.org; Mon, 29 Dec 2008 14:10:23 -0500 Original-Received: from [199.232.76.173] (port=42002 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LHNVO-0005vQ-Om for emacs-devel@gnu.org; Mon, 29 Dec 2008 14:10:22 -0500 Original-Received: from sallyv2.ics.uci.edu ([128.195.1.120]:34519) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1LHNVO-0007en-8V for emacs-devel@gnu.org; Mon, 29 Dec 2008 14:10:22 -0500 Original-Received: from mothra.ics.uci.edu (mothra.ics.uci.edu [128.195.6.93]) by sallyv2.ics.uci.edu (8.13.7+Sun/8.13.7) with ESMTP id mBTJAExW005968 for ; Mon, 29 Dec 2008 11:10:14 -0800 (PST) Original-Received: (from dann@localhost) by mothra.ics.uci.edu (8.13.8+Sun/8.13.6/Submit) id mBTJAEUT027466; Mon, 29 Dec 2008 11:10:14 -0800 (PST) In-Reply-To: <200812221802.mBMI28aU001131@mothra.ics.uci.edu> (Dan Nicolaescu's message of "Mon, 22 Dec 2008 10:02:08 -0800 (PST)") Original-Lines: 99 X-ICS-MailScanner-Information: Please contact the ISP for more information X-ICS-MailScanner-ID: mBTJAExW005968 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam, SpamAssassin (score=-0.34, required 5, autolearn=disabled, ALL_TRUSTED -1.44, FM_MULTI_ODD2 1.10) X-ICS-MailScanner-From: dann@mothra.ics.uci.edu X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:107382 Archived-At: Dan Nicolaescu 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?