[thread] Patch: suppress report of tss_hook "leak"

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[thread] Patch: suppress report of tss_hook "leak"

Kevin Bluck
Recently I took up with the thread library. Using MSVC, I quickly ran afoul
of a memory leak report from the CRT debugger. Naturally assuming that I am
more likely to screw up than a well-reviewed library, I spent a not
insignificant amount of effort trying to track down my own stupid mistake.
Eventually realizing the cause was in boost.thread, I spent more time
researching and finally discovering this thread:
http://lists.boost.org/boost-users/2005/08/13538.php Apparently, this issue
is well understood and the consensus is that it is benign and the CRT is
just being overly pedantic.

Although I understand that the issue is generally not regarded as a bug or
even a "memory leak" as such, I can't help but imagine that other library
users are in the same boat as me. I decided it would be nice if MSVC didn't
unnecessarily alarm ignorant newcomers like myself and continually annoy
others who understand the issue but have a personal conviction against
allowing lint in their builds. So, if there is no plan to change the
underlying issue, I figured I could at least shut up MSVC.

Attached is a patch for tss_hook.cpp, which uses the function _CrtSetDbgFlag
to temporarily turn off heap allocation tracking for the particular
allocation in question. It should have no effect except on MSVC debug
builds. On my configuration (msvc-8_0) it successfully eliminates the leak
warnings. I figure it's the moral equivalent of suppressing a warning that
can't reasonably be eliminated otherwise.

I hope it seems useful.

--- Kevin

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

tss_hooks.cpp.diff (1K) Download Attachment