Potential Memory Leak in RunThread: Unfreed Gb.Alpns and Inner Buffers

Open Beginner friendly
#5,204 0 comments 0 reactions 0 assignees View on GitHub

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

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

Area: Testing HowFound: MSR Triaged

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/msquic

All issues in microsoft/msquic

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.