From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: port-for-each vs lazy sweep Date: Sun, 19 Aug 2007 11:22:27 +1000 Message-ID: <878x88pbcc.fsf@zip.com.au> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1187486562 23341 80.91.229.12 (19 Aug 2007 01:22:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 19 Aug 2007 01:22:42 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Aug 19 03:22:41 2007 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IMZV2-0007Cm-If for guile-devel@m.gmane.org; Sun, 19 Aug 2007 03:22:40 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IMZV1-0002jn-Ns for guile-devel@m.gmane.org; Sat, 18 Aug 2007 21:22:39 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IMZUy-0002jO-Nm for guile-devel@gnu.org; Sat, 18 Aug 2007 21:22:36 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IMZUw-0002j0-FN for guile-devel@gnu.org; Sat, 18 Aug 2007 21:22:35 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IMZUw-0002ix-8a for guile-devel@gnu.org; Sat, 18 Aug 2007 21:22:34 -0400 Original-Received: from mailout1-1.pacific.net.au ([61.8.2.208] helo=mailout1.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IMZUw-0007Xm-4S for guile-devel@gnu.org; Sat, 18 Aug 2007 21:22:34 -0400 Original-Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.2.163]) by mailout1.pacific.net.au (Postfix) with ESMTP id C60C5397AA6 for ; Sun, 19 Aug 2007 11:22:29 +1000 (EST) Original-Received: from localhost (ppp2946.dyn.pacific.net.au [61.8.41.70]) by mailproxy2.pacific.net.au (Postfix) with ESMTP id 2820B27410 for ; Sun, 19 Aug 2007 11:22:29 +1000 (EST) Original-Received: from gg by localhost with local (Exim 4.67) (envelope-from ) id 1IMZUp-0002qZ-U1 for guile-devel@gnu.org; Sun, 19 Aug 2007 11:22:27 +1000 User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux) X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:6702 Archived-At: I've struck, in 1.8, port-for-each passing a freed cell to its iterator func. Eg. "guile -s foo.scm" on (define lst '()) (gc) (gc) (gc) (make-list 1000) (open-input-file "/etc/passwd") (make-list 1000) (open-input-file "/etc/passwd") (make-list 1000) (open-input-file "/etc/passwd") (make-list 1000) (open-input-file "/etc/passwd") (gc) (port-for-each (lambda (port) (set! lst (cons port lst)))) (gc) (gc) (gc) (display lst) (newline) gives (# # # # # # # # #) I suspect the opened ports are correctly found to be unused and left unmarked by the gc, but they remain in the port table. port-for-each then passes them to its func and a little later the sweep gets to them and they turn into freed cells. (I noticed this when printing ports from within port-for-each as a diagnostic.) I suppose either port-for-each should ignore ports which are unmarked and unswept; or the gc should sweep the port table entries immediately instead of lazily. Neither sounds pretty, but the latter might be safer than letting zombies remain in the port table. I suspect for instance `flush-all' could suffer the same problem if it does a callback to a soft port flush function (or a C code ptob flush func if that somehow provoked some sweeping). (This got me wondering why there's a port table anyway, instead of independent objects with say a weak hash table for the "list of all ports" needed by port-for-each and flush-all. Historical reasons I suppose.) _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel