From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chris Vine Newsgroups: gmane.lisp.guile.bugs Subject: bug#19235: make-fresh-user-module procedure leaks memory Date: Sun, 30 Nov 2014 23:28:34 +0000 Message-ID: <20141130232834.32cbf5b2@bother.homenet> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1417390245 26923 80.91.229.3 (30 Nov 2014 23:30:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Nov 2014 23:30:45 +0000 (UTC) To: 19235@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Mon Dec 01 00:30:36 2014 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XvDwn-0002cn-LE for guile-bugs@m.gmane.org; Mon, 01 Dec 2014 00:30:34 +0100 Original-Received: from localhost ([::1]:52172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDwn-00007Y-7b for guile-bugs@m.gmane.org; Sun, 30 Nov 2014 18:30:33 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDwV-00006G-Kn for bug-guile@gnu.org; Sun, 30 Nov 2014 18:30:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XvDwL-0005cD-P6 for bug-guile@gnu.org; Sun, 30 Nov 2014 18:30:15 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDwL-0005bY-MK for bug-guile@gnu.org; Sun, 30 Nov 2014 18:30:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XvDwL-0002AY-D6 for bug-guile@gnu.org; Sun, 30 Nov 2014 18:30:05 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Chris Vine Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 30 Nov 2014 23:30:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 19235 X-GNU-PR-Package: guile X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14173901488121 (code B ref -1); Sun, 30 Nov 2014 23:30:05 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Nov 2014 23:29:08 +0000 Original-Received: from localhost ([127.0.0.1]:50210 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XvDvP-00026s-MO for submit@debbugs.gnu.org; Sun, 30 Nov 2014 18:29:07 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:48829) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XvDvN-00026f-5A for submit@debbugs.gnu.org; Sun, 30 Nov 2014 18:29:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XvDvD-00052W-5z for submit@debbugs.gnu.org; Sun, 30 Nov 2014 18:29:05 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:56536) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDvD-00052Q-2c for submit@debbugs.gnu.org; Sun, 30 Nov 2014 18:28:55 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDv5-00082v-Bg for bug-guile@gnu.org; Sun, 30 Nov 2014 18:28:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XvDuw-0004vv-LN for bug-guile@gnu.org; Sun, 30 Nov 2014 18:28:47 -0500 Original-Received: from smtpout3.wanadoo.co.uk ([80.12.242.59]:60772 helo=smtpout.wanadoo.co.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDuw-0004v3-CE for bug-guile@gnu.org; Sun, 30 Nov 2014 18:28:38 -0500 Original-Received: from laptop.homenet ([95.146.110.225]) by mwinf5d37 with ME id MzUb1p0024rpotr03zUbWR; Mon, 01 Dec 2014 00:28:35 +0100 X-ME-Helo: laptop.homenet X-ME-Date: Mon, 01 Dec 2014 00:28:35 +0100 X-ME-IP: 95.146.110.225 Original-Received: from bother.homenet (localhost [127.0.0.1]) by laptop.homenet (Postfix) with ESMTP id CCF938B70A for ; Sun, 30 Nov 2014 23:28:34 +0000 (GMT) X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; i686-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7648 Archived-At: The make-fresh-user-module procedure leaks memory in guile-2.0.11 as demonstrated by the attached test case. This test case should be invoked either with the "shared" or "fresh" option. If invoked with the "fresh" option, it will call make-fresh-user-module on each iteration through the loop. On my 32-bit machine it will steadily accumulate a memory leak before running out of memory on consuming approximately 2.2G memory, after about 180,000 iterations. If called with the "shared" option, it will accumulate no additional memory while executing, and will execute normally to the end of its iterations. The question which might be asked is "Would any sane person ever want to invoke the make-fresh-user-module procedure more than a few times in a practical program?". The answer to this question is "Yes", if guile is being used as an extension framework for a C or C++ program, and it executes guile extensions as individual tasks, and it is necessary that top levels should not to be shared. The execution of tasks concurrently is one such case, but there can be many cases where isolated top levels are desirable for tasks executed serially also. Test case: ----------------------------- snip ----------------------------- /* compile with 'gcc -O2 -Wall `pkg-config --cflags --libs guile-2.0` -o test-guile' */ #include #include #include #include int fresh; void* func (void* data) { switch (fresh) { case 0: scm_c_eval_string(""); break; default: scm_c_eval_string("(set-current-module (make-fresh-user-module))"); } return NULL; } int main (int argc, char *argv[]) { int count; if (argc != 2 || (strcmp (argv[1], "shared") && strcmp (argv[1], "fresh"))) { puts ("Usage: test-guile shared | fresh"); exit (1); } if (!strcmp (argv[1], "fresh")) { puts("Invoking make-fresh-user-module"); fresh = 1; } else puts("Using shared top level"); for (count = 0; count < 256000; ++count) { scm_with_guile(func, NULL); if (!(count % 100)) { printf("%d ", count); fflush(stdout); } usleep(1); } puts(""); return 0; }