I made a bug report in debian. See
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=541433
The patch is slightly different as it is only focused on the memory leak.
paul
Paul Sundvall skrev:
> Hi,
> I found a memory leak in main/sockets/src/sockets.cc. To trigger it:
>
> a)
> send data (here using netcat):
> $nc -l -p 9897 -q0 </dev/zero
>
> b)
> read it in octave:
>
> client = socket(AF_INET, SOCK_STREAM, 0);
> server_info = struct("addr", "127.0.0.1", "port", 9897);
> rc = connect(client, server_info);
> while 1
> [msg_s, len_s] = recv(client,1000);
> end
>
> ...and after a while all memory is gone.
>
>
> The patch (obtained with svn diff) is as below. There are some other
> changes as well: cut/paste typo, a delete which should have been
> delete[]. I added a check for requesting negative receive length as well.
>
> svn diff
> Index: sockets.cc
> ===================================================================
> --- sockets.cc (revision 6087)
> +++ sockets.cc (arbetskopia)
> @@ -534,7 +534,7 @@
> for ( int i = 0 ; i < d1.length() ; i++ )
> buf[i] = (unsigned char)d1(i);
> retval = ::send( s->get_sock_fd(), (const char*)buf,
> data.byte_size(), 0 );
> - delete buf;
> + delete[] buf;
> }
> else
> {
> @@ -577,11 +577,14 @@
> }
> else
> {
> - error("connect: expecting a octave_socket or integer");
> + error("recv: expecting a octave_socket or integer");
> return octave_value(-1);
> }
>
> long len = args(1).int_value();
> + if(len<0)
> + error("recv: negative receive length requested");
> +
> unsigned char* buf = new unsigned char[ len ];
> #ifndef __WIN32__
> retval = ::recv( s->get_sock_fd(), buf, len, flags );
> @@ -594,6 +597,8 @@
> for ( int i = 0 ; i < retval ; i++ )
> return_buf(0,i) = buf[i];
>
> + delete[] buf;
> +
> octave_value in_buf(return_buf);
> octave_value out_buf;
> OCTAVE_TYPE_CONV( in_buf, out_buf, uint8 );
>
>
>
> I would appreciate if I am allowed to join the octave with commit right.
> My username is paulsundvall.
>
> thanks,
> paul
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Octave-dev mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/octave-dev
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev