User mode networking SLIRP rapid memory leak
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
QEMU |
Expired
|
Undecided
|
Unassigned |
Bug Description
QEMU compiled from git HEAD at 2d03b49c3f22599
This is the command I ran:
qemu-system-x86_64 -enable-kvm -smp 2 -m 1G -usbdevice tablet -net nic,model=e1000 -net user -vnc localhost:99 -drive if=ide,
The guest is Windows 7 64-bit. The VM starts off normally, but after a couple of minutes, the memory usage starts to swell. If let running, it eventually consumes all host memory and grinds the host to a halt due to heavy swapping.
When running under gdb, I set a breakpoint on mmap, and this is the stack trace I obtained.
Breakpoint 1, mmap64 () at ../sysdeps/
81 in ../sysdeps/
(gdb) where
#0 mmap64 () at ../sysdeps/
#1 0x00007ffff0e65091 in new_heap (size=135168, size@entry=1728,
top_
#2 0x00007ffff0e687b2 in sysmalloc (av=0x7fffd0000020, nb=1664)
at malloc.c:2386
#3 _int_malloc (av=0x7fffd0000020, bytes=1650) at malloc.c:3740
#4 0x00007ffff0e69f50 in __GI___libc_malloc (bytes=1650) at malloc.c:2855
#5 0x00005555557a091a in m_get (slirp=
at /src/qemu/
#6 0x00005555557a3151 in slirp_input (slirp=
pkt=
at /src/qemu/
#7 0x0000555555758b24 in net_slirp_receive (nc=<optimized out>,
buf=<optimized out>, size=54) at /src/qemu/
#8 0x00005555557567d1 in qemu_deliver_packet (sender=<optimized out>,
flags=
opaque=
#9 0x00005555557588d3 in qemu_net_
data=
queue=
#10 qemu_net_queue_send (queue=
data=
at /src/qemu/
---Type <return> to continue, or q <return> to quit---
#11 0x000055555575536b in net_hub_receive (len=54, buf=0x7ffff7e94b20 "RU\n",
source_
#12 net_hub_
at /src/qemu/
#13 0x00005555557567d1 in qemu_deliver_packet (sender=<optimized out>,
flags=
opaque=
#14 0x00005555557588d3 in qemu_net_
data=
queue=
#15 qemu_net_queue_send (queue=
data=
at /src/qemu/
#16 0x00005555556db95d in xmit_seg (s=0x7ffff7e72010)
at /src/qemu/
#17 0x00005555556dbd38 in process_tx_desc (dp=0x7fffdf7fda30, s=0x7ffff7e72010)
at /src/qemu/
#18 start_xmit (s=0x7ffff7e72010) at /src/qemu/
#19 set_tctl (s=0x7ffff7e72010, index=<optimized out>, val=<optimized out>)
at /src/qemu/
#20 0x0000555555840fb0 in access_
value=
access_
---Type <return> to continue, or q <return> to quit---
access=
at /src/qemu/
#21 0x00005555558462fe in memory_
addr=14360, mr=0x7ffff7e747c0) at /src/qemu/
#22 io_mem_write (mr=0x7ffff7e747c0, addr=14360, val=<optimized out>, size=4)
at /src/qemu/
#23 0x00005555557e8717 in address_space_rw (
as=
buf=
at /src/qemu/
#24 0x000055555583ff65 in kvm_cpu_exec (cpu=<optimized out>)
at /src/qemu/
#25 0x00005555557ddb6c in qemu_kvm_
at /src/qemu/
#26 0x00007ffff11b6182 in start_thread (arg=0x7fffdf7f
at pthread_
#27 0x00007ffff0ee1b2d in clone ()
at ../sysdeps/
Let me know if you have any questions. Thanks.
liulk
Changed in qemu: | |
status: | Incomplete → Triaged |
I investigated further and found that a program in guest (jusched.exe Java Updater) is simultaneously sending and receiving network packets rapidly. This is what exacerbates the memory leak.
When the mmap breakpoint triggers, I now set additional breakpoints in m_get() and m_free() and found that the number of calls to these functions do not balance, hence making the leak evident.
Breakpoint 1, mmap64 () at ../sysdeps/ unix/syscall- template. S:81 unix/syscall- template. S unix/syscall- template. S:81
at /src/qemu/ slirp/mbuf. c:66
at /src/qemu/ slirp/mbuf. c:103
81 in ../sysdeps/
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x00007ffff0edbfb0 ../sysdeps/
breakpoint already hit 6 times
2 breakpoint keep y 0x0000555555848dfa in m_get
breakpoint already hit 645487 times
ignore next 354513 hits
3 breakpoint keep y 0x0000555555848eff in m_free
breakpoint already hit 484477 times
ignore next 515523 hits
About 25% of the m_get() do not get m_free()'d.
liulk