-
Notifications
You must be signed in to change notification settings - Fork 123
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
Introduce basic leak checking into the validation layer #318
Conversation
9d585bf
to
8247f24
Compare
Two thoughts. Just printing pointers to leaked objects is not super useful, consider printing backtraces (see |
b0b8668
to
7cad7bc
Compare
I've added backtrace logging for the references retained after |
6cdc250
to
9f89071
Compare
7645970
to
98bcbf7
Compare
@pbalcer what do you think about linking the loader with dbghelp Windows lib? |
dc1e1e2
to
8ebd7a8
Compare
it->second.refCount++; | ||
return std::make_pair(it->first, it->second.refCount); | ||
} else { | ||
counts.emplace(ptr, createRefInfo(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should differentiate between create/retain/release. It will allow you to find issues when retain is called on an object that wasn't created properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The origin of those calls should be visible in backtrace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but the way you have it, doing:
retain(0xCAFE);
retain(0xCAFE);
release(0xCAFE);
release(0xCAFE);
Would be a perfectly valid sequence of calls. That's why I think special-casing create
here makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've modified the leak-checking mechanism to differentiate between *Create/*Retain/*Release calls.
According to docs, "DbgHelp.dll ships with all versions of Windows", so I don't see a problem with always linking it in. |
547c707
to
6d74a62
Compare
it->second.refCount++; | ||
return std::make_pair(it->first, it->second.refCount); | ||
} else { | ||
counts.emplace(ptr, createRefInfo(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but the way you have it, doing:
retain(0xCAFE);
retain(0xCAFE);
release(0xCAFE);
release(0xCAFE);
Would be a perfectly valid sequence of calls. That's why I think special-casing create
here makes sense.
6d74a62
to
ec66986
Compare
scripts/templates/valddi.cpp.mako
Outdated
@@ -16,18 +17,24 @@ from templates import helper as th | |||
* @file ${name}.cpp | |||
* | |||
*/ | |||
#include "${x}_validation_layer.hpp" | |||
#include "ur_leak_check.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using the ${x} for a varying prefix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd forgotten about it. Should be fine now.
ec66986
to
235147e
Compare
Leak checking is performed by tracking the *Create/*Retain/*Release calls.
It can be controlled through
UR_ENABLE_LEAK_CHECKING
environmental variable.Related issue: #144.
Depends on: #154.