bugGuile - Bugs: bug #34029, mem leak in objcodes.c and vm.c

 
 

bug #34029: mem leak in objcodes.c and vm.c

Submitted by:  Stefan Israelsson Tampe <tampe>
Submitted on:  Tue 16 Aug 2011 08:25:35 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 22 Oct 2011 02:22:09 PM UTC, comment #1:

Fixed some time ago in fb031aba, thanks!

Ludovic Courtès <civodul>
Project Administrator
Tue 16 Aug 2011 08:25:35 PM UTC, original submission:

>>>>>>>>>>>> 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

Stefan Israelsson Tampe <tampe>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by civodul (Posted a comment)
  • -unavailable- added by tampe (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 22 Oct 2011 02:22:09 PM UTCcivodulOpen/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1