- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've got an application with a number of DLLs and I've enabled the automatic replacement of malloc/free by including:
#include "tbb/tbbmalloc_proxy.h"
into the cpp that contains the WinMain for my application (i.e. cpp of my exe).
When I run in debug mode I get some RtlValidateErrors after this change, so I did some debugging and found that news/deletes called in global constructors in my dlls can before the patching of the mallocs bydoMallocReplacement which leads to mis-matching of memory allocation/deallocation calls.
Any solutions for this issue?
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
this is unusual behaviour, memory which was allocated by standard crt should be deallocated by standard crt via forward from scallable_free/delete.
when do you get the errors, during realloc?
and which tbb version and runtime version do you use (arhitecture and dll name/version)?
thanks,
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It looks like the problem is that these news happen before tbmalloc redirection code takes effect. The reason for this seems to be that the DllCRTInitialization for these dlls runs before the same named routine for tbmalloc_proxy (which calls the redirection function AFAIK). DllCRTInitializationfor my Dlls calls CRT_INIT which initializes global objects in my dll and these global objects make calls to new. So these news happen before the redirection takes place.
I'm using the latest version of the tbmalloc code I believe (tbmalloc_debug.dll has file version 3.0.2011.704, for example).
If it would be helpful, I can probably create a simple test case that duplicates the problem I think.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting dan@syncad.com
If it would be helpful, I can probably create a simple test case that duplicates the problem I think.
it would be great.
--Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I couldn't duplicate it with a simple test case, so I went back and scoured the code base with the problem more thoroughly and I found some code that overrode the microsoft new/deletes already for some memory tracking reasons. The code wasn't really used anymore (it was only there for diagnostic purposes during development), but something about it's continued existence cause the problem. I removed these files from the build and it works now (although all my news/deletes still aren't being caught by the "automatic" header, unfortunately, so I'm still left to add new/delete overrides on many of my classes). So I guess this issue can be closed, assuming it's known that the "automatic" header doesn't override all news/deletes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The allocator replacement only overrides global new and delete operators provided as entry points by MSVCRT, but is unawareof any overloads. If you think your new/delete operations are global and should be overridden but aren't, please try making a reproducer and we will take a look.
Thank you for the feedback that helpsimproving TBB!
Thank you for the feedback that helpsimproving TBB!
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page