Potential Memory Leak in RunThread: Unfreed Gb.Alpns and Inner Buffers
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- cpp
- Domain
- performance, tooling
Research direction
Inspect src/tools/spin/spinquic.cpp around the RunThread function at lines 1359-1503, starting with the Gb.Alpns and inner Buffer allocations. Trace every exit path and ensure the allocated QUIC_BUFFER array and its inner buffers are released. Run the SpinQuic stress or fuzz workload mentioned in the issue and verify that repeated thread executions no longer accumulate memory.
Written by the indexing model from the issue text.
Description
Description
In the CXPLAT_THREAD_CALLBACK(RunThread, Context) function, the Gb.Alpns array and its inner Buffer pointers are allocated with malloc but are never freed.
https://github.com/microsoft/msquic/blob/be90c9cead220b542e881ed3eb6b73be2360d8eb/src/tools/spin/spinquic.cpp#L1359-L1503
Problem Code Snippet:
Gb.Alpns = (QUIC_BUFFER*)malloc(sizeof(QUIC_BUFFER) * SpinSettings.SessionCount);
...
Gb.Alpns[j].Buffer = (uint8_t*)malloc(Gb.Alpns[j].Length);
These allocations are not cleaned up in the current implementation, which leads to memory leaks on every thread execution.
Impact
- For every invocation of RunThread, a number of heap-allocated QUIC_BUFFER entries and their inner Buffer arrays are leaked.
- When running fuzz tests or stress tests (e.g., SpinQuic), this may cause cumulative memory growth and potential OOM issues.
- Dominant language
- C
- Stars
- 4.8k
- Forks
- 698
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 35
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/msquic
-
Area: Build Triaged
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Area: Core HowFound: MSR Triaged
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
bvt ci-failure
All issues in microsoft/msquic
Similar issues
-
level/task module/gcp type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
P3 sonic-vpp
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sonic-net/sonic-buildimage#29662 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
spack/spack-packages#6586 ·
-
category:port-update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100