[cfe-dev] idea: feature to force cleanup of freed stack/heap - useful enough?
Kostya Serebryany
kcc at google.com
Wed Oct 30 08:44:30 PDT 2013
On Wed, Oct 30, 2013 at 1:49 AM, Dennis Luehring <dl.soluz at gmx.net> wrote:
> it would be nice to have an clang feature to instrument cleanup freed
> stack/heap space
> with an defined bit pattern (0, 0xfff...,) - this way it would be easier
> to find stack/heap missuse
>
> before dtor end(exception chain) the object space will be nulled
> before function/method/ctor end(exception chain) stack space will be nulled
> before mallocs-free the allocated space is nulled (problematic when using
> other librarys)
>
> i little bit in the area of the addresssanitizer but should be faster, but
> without the auto-detection of missuse
>
> what do you think
>
These are two different tasks: heap and stack.
For heap, you need to change the malloc implementation, not clang/llvm.
In fact, many malloc implementation do this already in debug mode.
For stack, yes, you can to this.
It will be rather expensive -- in some cases more expensive than what asan
does (!!).
Consider you have a function with a large stack frame, e.g. 8K, which is
called very frequently.
Your proposal means we need to memset 8K of stack on every call.
While asan only memsets 1K of shadow on every call.
--kcc
> ______________________________**_________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/**mailman/listinfo/cfe-dev<http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131030/52e74be6/attachment.html>
More information about the cfe-dev
mailing list