Skip to content

[CLIENT-3915] Reduce the number of reported stack traces for leaks by only showing definite leaks. This makes it easier to create a suppressions file that isn't too large.#1097

Draft
juliannguyen4 wants to merge 28 commits into
devfrom
CLIENT-3915-add-suppression-that-ignores-all-possibly-lost-or-reachable-stack-traces-without-client-lines
Draft

[CLIENT-3915] Reduce the number of reported stack traces for leaks by only showing definite leaks. This makes it easier to create a suppressions file that isn't too large.#1097
juliannguyen4 wants to merge 28 commits into
devfrom
CLIENT-3915-add-suppression-that-ignores-all-possibly-lost-or-reachable-stack-traces-without-client-lines

Conversation

@juliannguyen4

@juliannguyen4 juliannguyen4 commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Test plan

  • Massif should still work
  • Valgrind + specific test files

Only show definite leaks to reduce the number of suppressions we need to save. When running python3 -c "1" installed with valgrind, PYTHONMALLOC=malloc, and the default suppressions file in the python/cpython repo, most of the false positive leaks are categorized as "possibly lost" and a few are "reachable". I believe memory leaks are more likely to happen in the Python client because of "definitely lost" leaks; I don't think that the client code usually moves pointers of heap allocated memory to point somewhere in between that section, which would lead to "possibly lost" leaks.

I also don't believe reachable leaks would usually lead to an out of memory error since there's still a reference to those memory allocations.

There is an alternate PR for this ticket that attempts to create a suppressions file with all the "possibly lost" and "reachable" leaks found from running the dev tests, but that file is extremely large. #881

Extra changes

Always generate suppressions in case new ones needs to be added to the existing suppressions

TODO

  • Add appropriate copyright notices for valgrind suppressions file
  • There is a risk these suppressions can cause false negatives

… to save. When running Python with valgrind, PYTHONMALLOC=malloc, and the default suppressions file in python/cpython, most of the false positive leaks are possibly lost and a few are reachable. I believe memory leaks are more likely to happen in the Python client with definitely lost leaks; I don't think the client moves the pointer to heap allocated memory that much, which would lead to possibly lost leaks. Also I don't believe reachable leaks would usually lead to an out of memory error.
@codecov-commenter

codecov-commenter commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (dev@bc15a32). Learn more about missing BASE report.
⚠️ Report is 5 commits behind head on dev.

Additional details and impacted files
@@          Coverage Diff           @@
##             dev    #1097   +/-   ##
======================================
  Coverage       ?   85.38%           
======================================
  Files          ?      101           
  Lines          ?    14608           
  Branches       ?        0           
======================================
  Hits           ?    12473           
  Misses         ?     2135           
  Partials       ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…ssion-that-ignores-all-possibly-lost-or-reachable-stack-traces-without-client-lines
…ssion-that-ignores-all-possibly-lost-or-reachable-stack-traces-without-client-lines
…run valgrind multiple times to see if these suppressions are good enough to generate a stable baseline.
@juliannguyen4 juliannguyen4 changed the title [CLIENT-3915] Reduce the number of reported stack traces for leaks in the valgrind logs. This should make it easier to create a suppressions file that isn't too large. [CLIENT-3915] Reduce the number of reported stack traces for leaks by only showing definite leaks. This makes it easier to create a suppressions file that isn't too large. Jun 23, 2026
@juliannguyen4

juliannguyen4 commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator Author

Manual testing

  • Valgrind now passes 5 times with the suppressions file and with errors enabled for definite leaks.

…ssion-that-ignores-all-possibly-lost-or-reachable-stack-traces-without-client-lines
…ssion-that-ignores-all-possibly-lost-or-reachable-stack-traces-without-client-lines
… Geospatial leaks. We run with num-callers set to 500 and remove the custom suppressions so that they do not hide the Geospatial leaks. TODO - merge this branch into CLIENT-3913 branch to verify the leaks are gone.
…ssion-that-ignores-all-possibly-lost-or-reachable-stack-traces-without-client-lines
…s don't show up. There are still a lot of large stack traces from CPython without any client lines, and it's not clear whether those blocks are real leaks or not.
…fault suppressions for leaks actually works.. somehow I missed this :/
…more specific re: whether they come from the client or not. This way I can filter outfor only client lines.
…here the tests are run to avoid having to set GITHUB_ENV. Use grep to fail job if there are stack traces that come from the client code.
…is ensures that valgrind memory errors will be printed at the same time that the running tests are printed. This makes it easier to deduce where memory errors come from.
…nt instead of readarray which separates elements by newline chars.
…pipe getting stdin redirected from stdout to custom FD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants