Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disconnected mosh-server leaks memory #184

Closed
kmcallister opened this issue Apr 15, 2012 · 2 comments
Closed

disconnected mosh-server leaks memory #184

kmcallister opened this issue Apr 15, 2012 · 2 comments

Comments

@kmcallister
Copy link
Contributor

When I run mosh, kill the client with SIGKILL, and strace the server, I see a few calls to brk(2) with each heartbeat packet. /proc/$pid/maps confirms that the heap mapping is growing.

Here's a GDB backtrace of one of these brks.

#0  __brk (addr=0x7f2387a07000) at ../sysdeps/unix/sysv/linux/x86_64/brk.c:29
#1  0x00007f238384b8cd in *__GI___sbrk (increment=135168) at sbrk.c:54
#2  0x00007f23837f6729 in *__GI___default_morecore (increment=139790576021504)
    at morecore.c:49
#3  0x00007f23837f2f26 in sYSMALLOc (av=<optimized out>, nb=<optimized out>)
    at malloc.c:3197
#4  _int_malloc (av=0x7f2383afce60, bytes=5040) at malloc.c:4747
#5  0x00007f23837f48d0 in *__GI___libc_malloc (bytes=5040) at malloc.c:3660
#6  0x00007f2383ffbd0d in operator new(unsigned long) ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007f238542331d in allocate (__n=<optimized out>, this=<optimized out>)
    at /usr/include/c++/4.6/ext/new_allocator.h:92
#8  _M_allocate (__n=<optimized out>, this=<optimized out>)
    at /usr/include/c++/4.6/bits/stl_vector.h:150
#9  _Vector_base (__n=<optimized out>, this=0x7f23879c8400, __a=...)
    at /usr/include/c++/4.6/bits/stl_vector.h:123
#10 vector (__x=..., this=0x7f23879c8400) at /usr/include/c++/4.6/bits/stl_vector.h:279
#11 Row (this=0x7f23879c8400) at ./../terminal/terminalframebuffer.h:107
#12 _Construct<Terminal::Row, Terminal::Row> (__value=..., __p=0x7f23879c8400)
    at /usr/include/c++/4.6/bits/stl_construct.h:84
#13 __uninit_copy<std::_Deque_iterator<Terminal::Row, Terminal::Row const&, Terminal::Row const*>, std::_Deque_iterator<Terminal::Row, Terminal::Row&, Terminal::Row*> > (
    __result=..., __last=..., __first=...)
    at /usr/include/c++/4.6/bits/stl_uninitialized.h:77
#14 uninitialized_copy<std::_Deque_iterator<Terminal::Row, Terminal::Row const&, Terminal::Row const*>, std::_Deque_iterator<Terminal::Row, Terminal::Row&, Terminal::Row*> > (
    __result=..., __last=..., __first=...)
    at /usr/include/c++/4.6/bits/stl_uninitialized.h:119
#15 std::__uninitialized_copy_a<std::_Deque_iterator<Terminal::Row, Terminal::Row const&, Terminal::Row const*>, std::_Deque_iterator<Terminal::Row, Terminal::Row&, Terminal::Row*>, Terminal::Row> (__first=..., __last=..., __result=...)
    at /usr/include/c++/4.6/bits/stl_uninitialized.h:259
#16 0x00007f2385424619 in deque (__x=..., this=0x7f23879c7f88)
    at /usr/include/c++/4.6/bits/stl_deque.h:832
#17 Framebuffer (this=0x7f23879c7f88) at ./../terminal/terminalframebuffer.h:225
#18 Emulator (this=0x7f23879c7f88) at ./../terminal/terminal.h:34
#19 Terminal::Complete::Complete (this=0x7f23879c7f70)
    at ./../statesync/completeterminal.h:31
#20 0x00007f23854277c1 in TimestampedState (this=0x7f23879c7f60)
    at ./../network/transportstate.h:24
#21 construct (__val=..., __p=0x7f23879c7f60, this=<optimized out>)
    at /usr/include/c++/4.6/ext/new_allocator.h:108
#22 _M_create_node (__x=..., this=<optimized out>)
    at /usr/include/c++/4.6/bits/stl_list.h:476
#23 _M_insert (__position=..., __x=..., this=0x7f23875f4630)
    at /usr/include/c++/4.6/bits/stl_list.h:1515
#24 push_back (__x=..., this=0x7f23875f4630) at /usr/include/c++/4.6/bits/stl_list.h:988
#25 Network::TransportSender<Terminal::Complete>::add_sent_state (this=0x7f23875f4420,
    the_timestamp=<optimized out>, num=<optimized out>, state=...)
    at ./../network/transportsender.cc:182
#26 0x00007f23854280ff in Network::TransportSender<Terminal::Complete>::send_empty_ack (
    this=0x7f23875f4420) at ./../network/transportsender.cc:172
#27 0x00007f23854283c9 in Network::TransportSender<Terminal::Complete>::tick (
    this=0x7f23875f4420) at ./../network/transportsender.cc:147
#28 0x00007f2385420d1a in tick (this=0x7f23875f4390)
    at ./../network/networktransport.h:60
#29 serve (host_fd=5, terminal=..., network=...) at mosh-server.cc:633
#30 0x00007f23854218ea in run_server (desired_ip=0x7f23875f11c0 "127.0.0.1",
    desired_port=<optimized out>, command=0x7fffcde6df40, colors=8, verbose=false)
    at mosh-server.cc:380
#31 0x00007f238541f9b2 in main (argc=<optimized out>, argv=<optimized out>)
    at mosh-server.cc:234

This is on Debian amd64 with Mosh compiled from Git.

@keithw
Copy link
Member

keithw commented Apr 16, 2012

Do you see it growing forever, or is it bounded? We only save 32 states in
add_sent_state(), so intended behavior is that it should stop growing after
roughly 90 seconds.
On Apr 15, 2012 7:51 PM, "Keegan McAllister" <
reply@reply.github.com>
wrote:

When I run mosh, kill the client with SIGKILL, and strace the server,
I see a few calls to brk(2) with each heartbeat packet.
/proc/$pid/maps confirms that the heap mapping is growing.

Here's a GDB backtrace of one of these brks.

#0 __brk (addr=0x7f2387a07000) at
../sysdeps/unix/sysv/linux/x86_64/brk.c:29
#1 0x00007f238384b8cd in ___GI___sbrk (increment=135168) at sbrk.c:54
#2 0x00007f23837f6729 in __GI___default_morecore
(increment=139790576021504)
at morecore.c:49
#3 0x00007f23837f2f26 in sYSMALLOc (av=, nb=)
at malloc.c:3197
#4 _int_malloc (av=0x7f2383afce60, bytes=5040) at malloc.c:4747
#5 0x00007f23837f48d0 in __GI___libc_malloc (bytes=5040) at
malloc.c:3660
#6 0x00007f2383ffbd0d in operator new(unsigned long) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x00007f238542331d in allocate (__n=,
this=)
at /usr/include/c++/4.6/ext/new_allocator.h:92
#8 _M_allocate (__n=, this=)
at /usr/include/c++/4.6/bits/stl_vector.h:150
#9 _Vector_base (__n=, this=0x7f23879c8400, __a=...)
at /usr/include/c++/4.6/bits/stl_vector.h:123
#10 vector (__x=..., this=0x7f23879c8400) at
/usr/include/c++/4.6/bits/stl_vector.h:279
#11 Row (this=0x7f23879c8400) at ./../terminal/terminalframebuffer.h:107
#12 _Construct<Terminal::Row, Terminal::Row> (__value=...,
__p=0x7f23879c8400)
at /usr/include/c++/4.6/bits/stl_construct.h:84
#13 __uninit_copy<std::Deque_iterator<Terminal::Row, Terminal::Row
const&, Terminal::Row const
>, std::_Deque_iterator<Terminal::Row,
Terminal::Row&, Terminal::Row
> > (
__result=..., __last=..., __first=...)
at /usr/include/c++/4.6/bits/stl_uninitialized.h:77
#14 uninitialized_copy<std::_Deque_iterator<Terminal::Row,
Terminal::Row const&, Terminal::Row const
>,
std::_Deque_iterator<Terminal::Row, Terminal::Row&, Terminal::Row*> > (
__result=..., __last=..., __first=...)
at /usr/include/c++/4.6/bits/stl_uninitialized.h:119
#15 std::__uninitialized_copy_a<std::_Deque_iterator<Terminal::Row,
Terminal::Row const&, Terminal::Row const*>,
std::_Deque_iterator<Terminal::Row, Terminal::Row&, Terminal::Row*>,
Terminal::Row> (__first=..., __last=..., __result=...)
at /usr/include/c++/4.6/bits/stl_uninitialized.h:259
#16 0x00007f2385424619 in deque (__x=..., this=0x7f23879c7f88)
at /usr/include/c++/4.6/bits/stl_deque.h:832
#17 Framebuffer (this=0x7f23879c7f88) at
./../terminal/terminalframebuffer.h:225
#18 Emulator (this=0x7f23879c7f88) at ./../terminal/terminal.h:34
#19 Terminal::Complete::Complete (this=0x7f23879c7f70)
at ./../statesync/completeterminal.h:31
#20 0x00007f23854277c1 in TimestampedState (this=0x7f23879c7f60)
at ./../network/transportstate.h:24
#21 construct (__val=..., __p=0x7f23879c7f60, this=)
at /usr/include/c++/4.6/ext/new_allocator.h:108
#22 _M_create_node (__x=..., this=)
at /usr/include/c++/4.6/bits/stl_list.h:476
#23 _M_insert (__position=..., __x=..., this=0x7f23875f4630)
at /usr/include/c++/4.6/bits/stl_list.h:1515
#24 push_back (__x=..., this=0x7f23875f4630) at
/usr/include/c++/4.6/bits/stl_list.h:988
#25 Network::TransportSenderTerminal::Complete::add_sent_state
(this=0x7f23875f4420,
the_timestamp=, num=, state=...)
at ./../network/transportsender.cc:182
#26 0x00007f23854280ff in
Network::TransportSenderTerminal::Complete::send_empty_ack (
this=0x7f23875f4420) at ./../network/transportsender.cc:172
#27 0x00007f23854283c9 in
Network::TransportSenderTerminal::Complete::tick (
this=0x7f23875f4420) at ./../network/transportsender.cc:147
#28 0x00007f2385420d1a in tick (this=0x7f23875f4390)
at ./../network/networktransport.h:60
#29 serve (host_fd=5, terminal=..., network=...) at mosh-server.cc:633
#30 0x00007f23854218ea in run_server (desired_ip=0x7f23875f11c0
"127.0.0.1",
desired_port=, command=0x7fffcde6df40, colors=8,
verbose=false)
at mosh-server.cc:380
#31 0x00007f238541f9b2 in main (argc=, argv=)
at mosh-server.cc:234

This is on Debian amd64 with Mosh compiled from Git.


Reply to this email directly or view it on GitHub:
#184

@kmcallister
Copy link
Contributor Author

Ah, yes, it does eventually stop. At that point I see only poll and sendto. Sorry for the false alarm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants