# [bjj@sequent.com: memleak in tasks.c]

"Robert J. Brown" (rj@eli.wariat.org)
Fri, 23 May 1997 00:45:50 -0500

- Messages sorted by:[ date ][ thread ][ subject ][ author ]

    ------- Start of forwarded message -------
    Return-Path: nop@ccs.neu.edu
    X-Authentication-Warning: eng4.sequent.com: Host localhost didn't use HELO protocol
    To: moo-cows@the-b.org
    Subject: memleak in tasks.c
    Date: Thu, 22 May 97 16:39:16 PDT
    From: Ben Jackson <bjj@sequent.com>
    Sender: owner-moo-cows@the-b.org
    Precedence: bulk
    Resent-From: clue-cows <nop@nop.com>
    Errors-To: clue-cows <nop@nop.com>

    Jay found a particular structure element that seemed to be leaking and
    despite my disbelief I ran across it while reading tasks.c the next day.

    The leak happens when you kill_task a forked task which has not yet
    started to run.  One way to do this would be:

    	;;fork t (0) endfork ; kill_task(t);

    If this happens in a verb (rather than an eval) the strings that would
    be "leaked" would not actually be freed anyway (they would still be
    referenced by the object or the verb code) so the actual leak wouldn't
    happen until you decided to @rmverb or @program the verb, which may
    never happen in the life of the server.  It's pretty hard to make the
    server grow by any significant amount with this bug.

    Note that this is *not* "r2" specific, but the patch below is against
    r2 and may not apply cleanly to p6.  I trust if that's the case you can
    add the two lines by hand.  :-)

    - --Ben

    *** tasks.c	1997/03/08 06:25:43	1.3
    - --- tasks.c	1997/05/21 03:41:34	1.3.2.1
    ***************
    *** 319,327 ****
      	free_str(t->t.input.string);
      	break;
          case TASK_FORKED:
    ! 	if (strong)
      	    free_rt_env(t->t.forked.rt_env,
      			t->t.forked.program->num_var_names);
      	free_program(t->t.forked.program);
      	break;
          case TASK_SUSPENDED:
    - --- 319,330 ----
      	free_str(t->t.input.string);
      	break;
          case TASK_FORKED:
    ! 	if (strong) {
      	    free_rt_env(t->t.forked.rt_env,
      			t->t.forked.program->num_var_names);
    + 	    free_str(t->t.forked.a.verb);
    + 	    free_str(t->t.forked.a.verbname);
    + 	}
      	free_program(t->t.forked.program);
      	break;
          case TASK_SUSPENDED:
    ***************
    *** 1934,1942 ****
          register_function("flush_input", 1, 2, bf_flush_input, TYPE_OBJ, TYPE_ANY);
      }

    ! char rcsid_tasks[] = "$Id: tasks.c,v 1.3 1997/03/08 06:25:43 nop Exp $";

      /* $Log: tasks.c,v $
       * Revision 1.3  1997/03/08 06:25:43  nop
       * 1.8.0p6 merge by hand.
       *
    - --- 1937,1948 ----
          register_function("flush_input", 1, 2, bf_flush_input, TYPE_OBJ, TYPE_ANY);
      }

    ! char rcsid_tasks[] = "$Id: tasks.c,v 1.3.2.1 1997/05/21 03:41:34 bjj Exp $";

      /* $Log: tasks.c,v $
    +  * Revision 1.3.2.1  1997/05/21 03:41:34  bjj
    +  * Fix a memleak when a forked task was killed before it ever started.
    +  *
       * Revision 1.3  1997/03/08 06:25:43  nop
       * 1.8.0p6 merge by hand.
       *
    ------- End of forwarded message -------