-
Notifications
You must be signed in to change notification settings - Fork 2.7k
crtdbg: fix MSVC CRTDBG memory leak reporting #1460
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
Conversation
@dscho This is self-contained and Windows-specific. Let me know if you'd rather I send this upstream first. I wasn't sure about how much of the low level windows stuff is upstream. |
Teach git to report memory leaks both to a file and to the VS debug output window. From the SDK command line, build Git as follows: make MSVC=1 DEBUG=1 CRTDBG=1 When built this way, leaks will always be reported to the Visual Studio debug output window. Enable GIT_TRACE_CRTDBG and the leaks will also be reported to the trace target. This works from both the command line and from Visual Studio. Signed-off-by: Jeff Hostetler <[email protected]>
d5bdb54
to
ad909dd
Compare
The last 2 commits are probably duplicate too much code. These changes let us get the file/line of the I only converted the most common routines. I didn't really like how I had to do this (lots of duplicated |
Modify xcalloc(), xmalloc(), and xrealloc() macros to pass the file/line of the original caller to CRTDBG routines rather than the file/line of the x* routine itself. Signed-off-by: Jeff Hostetler <[email protected]>
7425b76
to
4ea09bc
Compare
Here is a version that tries to eliminate the duplicated code blocks and make minimal changes in upstream code sections. It might be possible to make this even skinnier, but I think this is pretty close. |
#undef malloc | ||
#undef realloc | ||
|
||
#define strdup(s) (_strdup_dbg((s), _NORMAL_BLOCK, caller_fn, caller_ln)) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
BTW, it's OK if you just want to say "no" on this PR. I understand. Memory leaks aren't taken that serious, since exit() works just fine for most uses. |
Thanks. I think I'd like the changes, though... I just need to understand the intricacies, and I need to come up with a way that would be acceptable by core Git. The less platform-specific stuff we can introduce outside |
return crtdbg_xmalloc(size, "kwset.c", -1); | ||
} | ||
#endif | ||
|
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
URL e.g git-for-windows/git#1460 near bottom
@jeffhostetler I'll close this for now, okay? If we need to resurrect it, we will probably have to redo it, what with |
that's fine. and yes, with all the changes to the build system since then, we'd need to retool it anyway. |
Teach git to report memory leaks both to a file and to the
VS debug output window.
From the SDK command line, build Git as follows:
When built this way, leaks will always be reported to the
Visual Studio debug output window.
Enable GIT_TRACE_CRTDBG and the leaks will also be reported
to the trace target. This works from both the command line
and from Visual Studio.
Signed-off-by: Jeff Hostetler [email protected]