Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture function info from call stack for memory leak detection. #1146

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jgonzalezdr
Copy link
Contributor

When the new operator override macros are not used (e.g. to avoid STL
errors), the function that called the new operator is traced by
inspecting the call stack.

Currently only works for GCC when the backtrace function is supported
(i.e. no support for MinGW).

When the new operator override macros are not used (e.g. to avoid STL
errors), the function that called the new operator is traced by
inspecting the call stack.

Currently only works for GCC when the backtrace function is supported
(i.e. no support for MinGW).
@coveralls
Copy link

coveralls commented Mar 19, 2018

Coverage Status

Coverage decreased (-0.3%) to 99.612% when pulling 175e585 on jgonzalezdr:memleak_callstack into 952bf2d on cpputest:master.

@jgonzalezdr
Copy link
Contributor Author

This is a preliminary PR just to discuss this feature, as started in #34. The next step I'll do is to call addr2line to obtain file and line info when printing report.

Afterwards, many different improvement can be done: Add support for Win32 equivalent functionality, maybe clang support also, partially import addr2line functionality to avoid executing external calls (and break dependency with addr2line being installed / accessible), etc.

Also, not related to mem leaks, I'll also explore adding callstack printing when a failure is raised.

Some specific tail call optimizations have been disabled in GCC and
Clang to ensure call stack distance is constant and consistent
@basvodde
Copy link
Member

Thanks for the initial PR. This will definitively not be integrated as-is. It'll require a lot of work still.

As a starting point though. Could you make a pull request for the rfind in SimpleString. But please rename it properly, fix the implementation to be more in the style of the rest of CppUTest, and add proper test to it. It is a good chance for practices TDD as it is such an isolated piece of code.

@basvodde
Copy link
Member

Also, the eventual implementation will need to be so that there are much much much less #if in the code.

@jgonzalezdr
Copy link
Contributor Author

@basvodde This is just a proof of concept, I wanted to keep it simple so you an others can test it a bit, see if it is useful, see quickly what needs to be changed, etc. A final version will definitely need some "preparation" PRs to make some structural changes, will need to add some optimization to keep the memory footprint of memory allocation info nodes the same than now, etc., but will of course be a bit more complex (even if tidier) and a bit harder to review.

Regarding the rfind functions, I've just cherry picked that quickly from a dangling branch I've got here for another feature I'm playing with, it's got its UT, so I can push that quickly. However, what do you mean by "fix the implementation to be more in the style of the rest of CppUTest"? Just code style?

@basvodde
Copy link
Member

Ok. I'll ignore this for now then :)

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.

None yet

3 participants