MOO-cows Mailing List Archive

[Prev][Next][Index][Thread]

Re: Memory Leak?



>I was browsing through the LambdaMOO 1.7.8p4 source, and I seem to have 
>come across a memory leak.

Been doing that myself recently.

>Would somebody be kind enough to double check and let me know if it is 
>indeed a memory leak or not?
>
>in tasks.c, the function do_command_task(), the last 'else' section, and 
>I quote the pertinant code:
>
>        else {
>            Var result, args;
>...[snip]
>            args = parse_into_wordlist(command);
>...[snip]
>            free_var(result);
>	}
>
>*should* have the last section read:
>
>            free_var(result);
>	    free_var(args);
>	}
>
>I checked to see if the lack of free_var(args) would in fact cause a
>memory leak, and it does seem to.  Past life regression therapy reveals:

I believe that the args are 'comsumed' (free'd) some place else in the call
chain (like in run_server_task or something).  Plus, if this was a memory
leak, it's such a big one, that someone would have noticed it a long time
ago (do_command_task() is called more often than not :) ).

>'Var args' is released by the call to do_command_task() (or, at least,
>that's what I can make out).  My appologies for the incorrect first post,
>I got confused with my earlier fiddling.  If you have the free_var(args)
>call with the free_var(result), you will panic your server, a unhappy 
>state of affairs indeed :)

Herf... I find panics to be better than the server just continuing on
blindly into bad code.  Got over 40 panics myself last night. :) 
Actually, I'm find this very confusing myself.  Could Pavel have installed
this (goofy?) system of free'ing just to confuse us and keep us from modding
the server? herf... anyway...

A related question:
I can't seem to get the entire argument list to a builtin function in
functions.c:call_bi_func.  Here's the code that's causing confusion:

functions.c:
>/*** calling built-in functions ***/
>
>package
>call_bi_func(unsigned n, Var arglist, Byte func_pc,
>             Objid progr, void *vdata)
>     /* requires arglist.type == TYPE_LIST
>        call_bi_func will free arglist */

Okay, I think I understand that... arglist needs to be a list.

But for some reason, I only end up with the first element when I use code
like (which appears not 10 lines later):

>    if (func_pc == 1) { /* check arg types and count *ONLY* for first entry */
>        int k, max;
>        Var *args = arglist.v.list;

Obviously, arglist.v.list contains the entire argument list, otherwise it
wouldn't be able to check all the types and count (I think).
I have a variable defined as:

Var *xargs = arglist.v.list;

But in a call to call_verb later on, in which I do use xargs, but the value
of args in the verb it's calling is not a list.  It's the value of the first
element of said list.  I think I'm figgling with arglist in the wrong way,
perhaps call_verb (or it's resulting functions) is expecting something
different.  If I set xargs = arglist, then I get an error later on also
(server panic, but I will have to check). Any ideas?  This comment and use
of arglist.v.list is really beating the hell outta me.


  ______                              __
    /   /                 _/_      / /  `  /)  /)       _/_
 --/   /_  , , , __.  __  /  _  __/ /--   //  //  __,_  /  _
(_/   / /_(_(_/_(_/|_/ (_<__</_(_/ (___, //__//__(_) (_<__/_)_
http://www.interaccess.com/users/abakun />  />
                                       </  </





Home | Subject Index | Thread Index