cloudflare / cloudflare/quiche
Memory leak with FFI on 0.20.1
- Dominant language
- Rust
- Stars
- 11.8k
- Forks
- 1.1k
- Avg merge
- 21h 9m
- Merged PRs (30d)
- 6
Description
For every stream connected/disconnected I get about 1,5kB of "possibly lost" memory from valgrind.
I see this memory growing over a few days, without ever being reclaimed, so I assume it's really lost.
Valgrind reports this 4 blocks for every stream:
==1604442== by 0x47F2F6: UnknownInlinedFun (alloc.rs:102)
==1604442== by 0x47F2F6: UnknownInlinedFun (alloc.rs:185)
==1604442== by 0x47F2F6: UnknownInlinedFun (alloc.rs:245)
==1604442== by 0x47F2F6: UnknownInlinedFun (alloc.rs:334)
==1604442== by 0x47F2F6: UnknownInlinedFun (boxed.rs:217)
==1604442== by 0x47F2F6: UnknownInlinedFun (sync.rs:369)
==1604442== by 0x47F2F6: UnknownInlinedFun (mod.rs:935)
==1604442== by 0x47F2F6: quiche::stream::recv_buf::RecvBuf::reset (recv_buf.rs:283)
==1604442== by 0x45D27E: quiche::Connection::process_frame (lib.rs:6744)
==1604442== by 0x44ECE7: recv_single (lib.rs:2791)
==1604442== by 0x44ECE7: quiche::Connection::recv (lib.rs:2187)
==1604442== by 0x2EE144: quiche_conn_recv (ffi.rs:744)
==1604442== by 0x4ADE25: alloc (alloc.rs:102)
==1604442== by 0x4ADE25: alloc_impl (alloc.rs:185)
==1604442== by 0x4ADE25: allocate (alloc.rs:245)
==1604442== by 0x4ADE25: exchange_malloc (alloc.rs:334)
==1604442== by 0x4ADE25: new> (boxed.rs:217)
==1604442== by 0x4ADE25: new (sync.rs:369)
==1604442== by 0x4ADE25: new (mod.rs:680)
==1604442== by 0x4ADE25: quiche::stream::StreamMap::get_or_create (mod.rs:301)
==1604442== by 0x45772C: get_or_create_stream (lib.rs:6647)
==1604442== by 0x45772C: quiche::Connection::stream_send (lib.rs:4636)
==1604442== by 0x2EE68A: quiche_conn_stream_send (ffi.rs:846)
==1604442== by 0x4C7027: alloc::raw_vec::finish_grow (raw_vec.rs:0)
==1604442== by 0x4C776E: grow_amortized (raw_vec.rs:404)
==1604442== by 0x4C776E: alloc::raw_vec::RawVec::reserve_for_push (raw_vec.rs:302)
==1604442== by 0x48AB73: alloc::collections::vec_deque::VecDeque::grow (mod.rs:2061)
==1604442== by 0x47F888: UnknownInlinedFun (mod.rs:1659)
==1604442== by 0x47F888: quiche::stream::send_buf::SendBuf::write (send_buf.rs:159)
==1604442== by 0x4579A1: quiche::Connection::stream_send (lib.rs:4672)
==1604442== by 0x2EE68A: quiche_conn_stream_send (ffi.rs:846)
==1604442== by 0x4C35F7: UnknownInlinedFun (alloc.rs:102)
==1604442== by 0x4C35F7: UnknownInlinedFun (alloc.rs:185)
==1604442== by 0x4C35F7: UnknownInlinedFun (alloc.rs:245)
==1604442== by 0x4C35F7: UnknownInlinedFun (boxed.rs:483)
==1604442== by 0x4C35F7: UnknownInlinedFun (boxed.rs:448)
==1604442== by 0x4C35F7: UnknownInlinedFun (node.rs:83)
==1604442== by 0x4C35F7: new_leaf (node.rs:217)
==1604442== by 0x4C35F7: alloc::collections::btree::map::entry::VacantEntry::insert (entry.rs:355)
==1604442== by 0x47E570: UnknownInlinedFun (map.rs:1006)
==1604442== by 0x47E570: quiche::stream::recv_buf::RecvBuf::write (recv_buf.rs:188)
==1604442== by 0x47F342: quiche::stream::recv_buf::RecvBuf::reset (recv_buf.rs:284)
==1604442== by 0x45D27E: quiche::Connection::process_frame (lib.rs:6744)
==1604442== by 0x44ECE7: recv_single (lib.rs:2791)
==1604442== by 0x44ECE7: quiche::Connection::recv (lib.rs:2187)
==1604442== by 0x2EE144: quiche_conn_recv (ffi.rs:744)
Contributor guide
Research direction
Reproduce the repeated stream connect/disconnect cycle under Valgrind, then inspect the allocation paths named in stream/recv_buf.rs, lib.rs, and ffi.rs, especially RecvBuf::reset, Connection::process_frame, quiche_conn_recv, and quiche_conn_stream_send. Done means identifying why the reported allocations remain after streams are disconnected and confirming with Valgrind that repeated cycles no longer grow memory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100