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#19236: load-compiled procedure leaks memory Date: Sun, 30 Nov 2014 23:30:09 +0000 Message-ID: <20141130233009.0e596015@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 1417390302 27844 80.91.229.3 (30 Nov 2014 23:31:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Nov 2014 23:31:42 +0000 (UTC) To: 19236@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Mon Dec 01 00:31:35 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 1XvDxl-00033z-Rv for guile-bugs@m.gmane.org; Mon, 01 Dec 2014 00:31:34 +0100 Original-Received: from localhost ([::1]:52177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDxl-0000MO-F8 for guile-bugs@m.gmane.org; Sun, 30 Nov 2014 18:31:33 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDxS-0000L9-Sg for bug-guile@gnu.org; Sun, 30 Nov 2014 18:31:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XvDxG-0006NK-Gq for bug-guile@gnu.org; Sun, 30 Nov 2014 18:31:14 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53004) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDxG-0006NG-Dr for bug-guile@gnu.org; Sun, 30 Nov 2014 18:31:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XvDxG-0002El-7x for bug-guile@gnu.org; Sun, 30 Nov 2014 18:31:02 -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:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 19236 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.14173902418532 (code B ref -1); Sun, 30 Nov 2014 23:31:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Nov 2014 23:30:41 +0000 Original-Received: from localhost ([127.0.0.1]:50217 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XvDwu-0002DX-EY for submit@debbugs.gnu.org; Sun, 30 Nov 2014 18:30:40 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49303) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XvDws-0002DM-Sy for submit@debbugs.gnu.org; Sun, 30 Nov 2014 18:30:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XvDwj-0005zt-14 for submit@debbugs.gnu.org; Sun, 30 Nov 2014 18:30:38 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:50713) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDwi-0005zi-Tl for submit@debbugs.gnu.org; Sun, 30 Nov 2014 18:30:28 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDwb-00006M-7P for bug-guile@gnu.org; Sun, 30 Nov 2014 18:30:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XvDwR-0005j1-Ti for bug-guile@gnu.org; Sun, 30 Nov 2014 18:30:21 -0500 Original-Received: from smtpout3.wanadoo.co.uk ([80.12.242.59]:32128 helo=smtpout.wanadoo.co.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDwR-0005im-NG for bug-guile@gnu.org; Sun, 30 Nov 2014 18:30:11 -0500 Original-Received: from laptop.homenet ([95.146.110.225]) by mwinf5d37 with ME id MzWA1p0084rpotr03zWAd0; Mon, 01 Dec 2014 00:30:11 +0100 X-ME-Helo: laptop.homenet X-ME-Date: Mon, 01 Dec 2014 00:30:11 +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 0AAFF8B70A for ; Sun, 30 Nov 2014 23:30:10 +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:7649 Archived-At: The load-compiled procedure leaks memory in guile-2.0.11 as demonstrated by the attached test case. It should be used in conjunction with a file 'test-file.scm' which contains only a single #f expression. This test case should be invoked either with the "pload" or "load" option. If invoked with the pload option, it will invoke primitive-load, which accumulates no additional memory while executing, and will execute normally to the end of its iterations. If invoked with the load option, on my 32-bit machine it will steadily accumulate a memory leak before running out of memory on consuming approximately 300M memory, after about 65,000 iterations. The memory leak seems to arise in guile's load-compiled procedure. The question which might be asked is "Would any sane person ever want to invoke the load (or load-compiled) procedures 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. Test case: ----------------------------- snip ----------------------------- /* compile with 'gcc -O2 -Wall `pkg-config --cflags --libs guile-2.0` -o test-guile' */ #include #include #include int load; void* func (void* data) { switch (load) { case 0: scm_c_eval_string("(primitive-load \"test-file.scm\")"); break; default: scm_c_eval_string("(load \"./test-file.scm\")"); } return NULL; } int main (int argc, char *argv[]) { int count; if (argc != 2 || (strcmp (argv[1], "pload") && strcmp (argv[1], "load"))) { puts ("Usage: test-guile load | pload"); exit (1); } if (!strcmp (argv[1], "load")) { puts("Using load"); load = 1; } else puts("Using primitive-load"); for (count = 0; count < 256000; ++count) { scm_with_guile(func, NULL); if (!(count % 100)) { printf("%d ", count); fflush(stdout); } } puts(""); return 0; }