From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.bugs Subject: [bug #34029] mem leak in objcodes.c and vm.c Date: Tue, 16 Aug 2011 20:25:36 +0000 Message-ID: <20110816-202535.sv78157.88968@savannah.gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=UTF-8 X-Trace: dough.gmane.org 1313526224 3569 80.91.229.12 (16 Aug 2011 20:23:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 16 Aug 2011 20:23:44 +0000 (UTC) To: Stefan Israelsson Tampe , bug-guile@gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Aug 16 22:23:40 2011 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QtQAj-00060I-Mg for guile-bugs@m.gmane.org; Tue, 16 Aug 2011 22:23:37 +0200 Original-Received: from localhost ([::1]:56673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtQAj-0007Cg-5S for guile-bugs@m.gmane.org; Tue, 16 Aug 2011 16:23:37 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:43534) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtQAg-0007CD-JI for bug-guile@gnu.org; Tue, 16 Aug 2011 16:23:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QtQAf-00062o-C7 for bug-guile@gnu.org; Tue, 16 Aug 2011 16:23:34 -0400 Original-Received: from savannah.gnu.org ([140.186.70.70]:45421 helo=frontend.savannah.gnu.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtQAf-00062j-6g for bug-guile@gnu.org; Tue, 16 Aug 2011 16:23:33 -0400 Original-Received: from www-data by frontend.savannah.gnu.org with local (Exim 4.72) (envelope-from ) id 1QtQCe-0004Nu-5l; Tue, 16 Aug 2011 20:25:36 +0000 X-PHP-Originating-Script: 0:sendmail.php X-Savane-Server: savannah.gnu.org:443 [140.186.70.70] X-Savane-Project: guile X-Savane-Tracker: bugs X-Savane-Item-ID: 34029 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101216 Linux Mint/1 (Debian) Firefox/3.6.13 X-Apparently-From: 82.182.254.46 (Savane authenticated user tampe) Original-References: In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.70 X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.14 Precedence: list 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:5775 Archived-At: URL: Summary: mem leak in objcodes.c and vm.c Project: Guile Submitted by: tampe Submitted on: Tue 16 Aug 2011 08:25:35 PM GMT Category: None Severity: 3 - Normal Item Group: None Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any _______________________________________________________ Details: >>>>>>>>>>>> Consider the following code, SCM_DEFINE (scm_objcode_to_bytecode, "objcode->bytecode", 1, 0, 0, (SCM objcode), "") #define FUNC_NAME s_scm_objcode_to_bytecode { scm_t_int8 *s8vector; scm_t_uint32 len; SCM_VALIDATE_OBJCODE (1, objcode); len = sizeof (struct scm_objcode) + SCM_OBJCODE_TOTAL_LEN (objcode); (0) s8vector = scm_malloc (len); memcpy (s8vector, SCM_OBJCODE_DATA (objcode), len); (1) return scm_c_take_bytevector (s8vector, len); } #undef FUNC_NAME ------------------------------------------------- (0) allocates s8vector using scm_malloc! (1) scm_c_take_bytevector put s8vector into a bytevector >>>>>>>>>>>> But in bytevector.c, / * Return a bytevector of size LEN made up of CONTENTS. The area pointed to by CONTENTS must have been allocated using `scm_gc_malloc ()'. */ SCM scm_c_take_bytevector (signed char *contents, size_t len) { return make_bytevector_from_buffer (len, contents, SCM_ARRAY_ELEMENT_TYPE_VU8); } ------------------------------------------------------------- scm_malloc does not allocate memory controlled by the gc and hece the gc will not free up the scm_malloced block! should be scm_gc_malloc_pointerless instead. ************************************************************* >>>>>>>>>>>>>> Also in vm.c, static SCM really_make_boot_program (long nargs) { SCM u8vec; scm_t_uint8 text[] = { scm_op_mv_call, 0, 0, 0, 1, scm_op_make_int8_1, scm_op_halt }; struct scm_objcode *bp; SCM ret; if (SCM_UNLIKELY (nargs > 255 || nargs < 0)) scm_misc_error ("vm-engine", "too many args when making boot procedure", scm_list_1 (scm_from_long (nargs))); text[1] = (scm_t_uint8)nargs; (0) bp = scm_malloc (sizeof (struct scm_objcode) + sizeof (text)); memcpy (SCM_C_OBJCODE_BASE (bp), text, sizeof (text)); bp->len = sizeof(text); bp->metalen = 0; (1) u8vec = scm_c_take_bytevector ((scm_t_int8*)bp, sizeof (struct scm_objcode) + sizeof (text)); ret = scm_make_program (scm_bytecode_to_objcode (u8vec), SCM_BOOL_F, SCM_BOOL_F); SCM_SET_CELL_WORD_0 (ret, SCM_CELL_WORD_0 (ret) | SCM_F_PROGRAM_IS_BOOT); return ret; } ------------------------------------------- (0),(1) the same suspect logic appears again (0) should contain scm_gc_malloc_pointerless _______________________________________________________ Reply to this item at: _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/