The original code is creating a future object on the heap, but does not delete it in one of the return paths causing a leak.
Because the lifetime of the future object is the local scope of its containing function, there's no need for heap-based allocation in the first place.
This diff fixes the memory leak by moving the future object allocation to stack-based RAII. There's no change to the functionality or style of the code.
Details
Details
- Reviewers
clayborg aadsm jingham JDevlieghere
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
lldb/tools/lldb-vscode/FifoFiles.cpp | ||
---|---|---|
53–54 | This comment seems to indicate we need to use a pointer. Seems like this should either be rewritten to not try to use a future with a timeout or left as is? |
lldb/tools/lldb-vscode/FifoFiles.cpp | ||
---|---|---|
53–54 | Good catch. Looks like the original code aims to intentionally orphan the 'future' object if it's blocked (possibly infinitely) in its destructor waiting for the executing thread to rejoin. This could happen if the workload uses blocking I/O calls like we have here. |
This comment seems to indicate we need to use a pointer. Seems like this should either be rewritten to not try to use a future with a timeout or left as is?