Re: [Freeciv-Dev] (PR#40209) A minor memory leak

2008-04-21 Thread Ulrik Sverdrup

http://bugs.freeciv.org/Ticket/Display.html?id=40209 >

2008/4/21, Marko Lindqvist <[EMAIL PROTECTED]>:
>
>  http://bugs.freeciv.org/Ticket/Display.html?id=40209 >
>
>
> On 21/04/2008, Elmo Todurov  wrote:
>  >
>  >  Now I want a cookie!
>  >  $ svn diff
>  >  Index: server/sernet.c
>  >  ===
>  >  --- server/sernet.c (revision 14605)
>  >  +++ server/sernet.c (working copy)
>  >  @@ -185,6 +185,7 @@
>  >line_internal = local_to_internal_string_malloc(line);
>  >(void) handle_stdin_input(NULL, line_internal, FALSE);
>  >free(line_internal);
>  >  +  free(line);
>  >
>  >readline_handled_input = TRUE;
>  >   }
>
>
>  Are you sure about this? Does readline really expect callback to free
>  the line? (and if it does, can it be bug in the specific readline
>  version you are using?)
>
>
>
>   - ML

A cursory look suggests Elmo is right.

That you should free the returned line is explicitly mentioned when
using the readline() call:

http://www.delorie.com/gnu/docs/readline/rlman_24.html#IDX174

No further mention at the reference for the alternative interface:

http://www.delorie.com/gnu/docs/readline/rlman_41.html#IDX288

Ulrik



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40209) A minor memory leak

2008-04-21 Thread Jason Dorje Short

http://bugs.freeciv.org/Ticket/Display.html?id=40209 >

Marko Lindqvist wrote:
> http://bugs.freeciv.org/Ticket/Display.html?id=40209 >
> 
> On 21/04/2008, Elmo Todurov  wrote:
>>  Now I want a cookie!
>>  $ svn diff
>>  Index: server/sernet.c
>>  ===
>>  --- server/sernet.c (revision 14605)
>>  +++ server/sernet.c (working copy)
>>  @@ -185,6 +185,7 @@
>>line_internal = local_to_internal_string_malloc(line);
>>(void) handle_stdin_input(NULL, line_internal, FALSE);
>>free(line_internal);
>>  +  free(line);
>>
>>readline_handled_input = TRUE;
>>   }
> 
>  Are you sure about this? Does readline really expect callback to free
> the line? (and if it does, can it be bug in the specific readline
> version you are using?)

Yeah it seems correct.  I've been seeing this leak in valgrind for a 
long time but never realized the free call had to go in that particular 
callback function.  Adding it there removes the warning.

==1040== 13 bytes in 1 blocks are definitely lost in loss record 1 of 17
==1040==at 0x4022AB8: malloc (vg_replace_malloc.c:207)
==1040==by 0x405BC21: xmalloc (in /lib/libreadline.so.5.2)
==1040==by 0x4044109: readline_internal_teardown (in 
/lib/libreadline.so.5.2)
==1040==by 0x4057867: rl_callback_read_char (in /lib/libreadline.so.5.2)
==1040==by 0x80FE355: server_sniff_all_input (sernet.c:691)
==1040==by 0x80B5B84: srv_main (srv_main.c:2201)
==1040==by 0x804ABEE: main (civserver.c:267)

-jason



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40209) A minor memory leak

2008-04-21 Thread Elmo Todurov

http://bugs.freeciv.org/Ticket/Display.html?id=40209 >

This patch is done in 2.1 branch. Apparently trunk has the same
problem (source hints so, haven't tested in Valgrind). Haven't checked
any other branches.



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40209) A minor memory leak

2008-04-21 Thread Marko Lindqvist

http://bugs.freeciv.org/Ticket/Display.html?id=40209 >

On 21/04/2008, Elmo Todurov  wrote:
>
>  Now I want a cookie!
>  $ svn diff
>  Index: server/sernet.c
>  ===
>  --- server/sernet.c (revision 14605)
>  +++ server/sernet.c (working copy)
>  @@ -185,6 +185,7 @@
>line_internal = local_to_internal_string_malloc(line);
>(void) handle_stdin_input(NULL, line_internal, FALSE);
>free(line_internal);
>  +  free(line);
>
>readline_handled_input = TRUE;
>   }

 Are you sure about this? Does readline really expect callback to free
the line? (and if it does, can it be bug in the specific readline
version you are using?)


 - ML



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40209) A minor memory leak

2008-04-21 Thread Elmo Todurov

http://bugs.freeciv.org/Ticket/Display.html?id=40209 >

Now I want a cookie!
$ svn diff
Index: server/sernet.c
===
--- server/sernet.c (revision 14605)
+++ server/sernet.c (working copy)
@@ -185,6 +185,7 @@
   line_internal = local_to_internal_string_malloc(line);
   (void) handle_stdin_input(NULL, line_internal, FALSE);
   free(line_internal);
+  free(line);

   readline_handled_input = TRUE;
 }



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev