unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* [bug #34029] mem leak in objcodes.c and vm.c
@ 2011-08-16 20:25 Stefan Israelsson Tampe
  2011-10-22 14:22 ` bug#9836: " Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Israelsson Tampe @ 2011-08-16 20:25 UTC (permalink / raw)
  To: Stefan Israelsson Tampe, bug-guile

URL:
  <http://savannah.gnu.org/bugs/?34029>

                 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:

  <http://savannah.gnu.org/bugs/?34029>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#9836: [bug #34029] mem leak in objcodes.c and vm.c
  2011-08-16 20:25 [bug #34029] mem leak in objcodes.c and vm.c Stefan Israelsson Tampe
@ 2011-10-22 14:22 ` Ludovic Courtès
  2011-10-22 15:59   ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2011-10-22 14:22 UTC (permalink / raw)
  To: ludo, stefan.itampe, 9836

Update of bug #34029 (project guile):

             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #1:

Fixed some time ago in fb031aba, thanks!

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?34029>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/






^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#9836: [bug #34029] mem leak in objcodes.c and vm.c
  2011-10-22 14:22 ` bug#9836: " Ludovic Courtès
@ 2011-10-22 15:59   ` Ludovic Courtès
  0 siblings, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2011-10-22 15:59 UTC (permalink / raw)
  To: 9836-done







^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-22 15:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-16 20:25 [bug #34029] mem leak in objcodes.c and vm.c Stefan Israelsson Tampe
2011-10-22 14:22 ` bug#9836: " Ludovic Courtès
2011-10-22 15:59   ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).