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

 
 

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

Submitter:  Stefan Israelsson Tampe <tampe>
Submitted:  Tue 16 Aug 2011 08:25:35 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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

Fixed some time ago in fb031aba, thanks!

Ludovic Courtès <civodul>
Group 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>
Group Member

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-10-22 civodul Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code