<div dir="ltr">On Mon, Feb 18, 2013 at 10:35 AM, Sean Silva <span dir="ltr"><<a href="mailto:silvas@purdue.edu" target="_blank" class="cremed">silvas@purdue.edu</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On Mon, Feb 18, 2013 at 8:31 AM, Kostya Serebryany <<a href="mailto:kcc@google.com" class="cremed">kcc@google.com</a>> wrote:<br>

> Hi,<br>
><br>
> Clang has two attributes to disable bug detection tools in a given function:<br>
><br>
> __attribute__((no_thread_safety_analysis)) disables clang's *static*<br>
> thread-safety analysis.<br>
> (<a href="http://clang.llvm.org/docs/LanguageExtensions.html#thread-safety-annotation-checking" target="_blank" class="cremed">http://clang.llvm.org/docs/LanguageExtensions.html#thread-safety-annotation-checking</a>)<br>

><br>
> __attribute__((no_address_safety_analysis)) disables AddressSanitizer<br>
> (*dynamic* analysis)<br>
> <a href="http://clang.llvm.org/docs/LanguageExtensions.html#extensions-for-dynamic-analysis" target="_blank" class="cremed">http://clang.llvm.org/docs/LanguageExtensions.html#extensions-for-dynamic-analysis</a><br>
><br>
> Now we need two more attributes to disable<br>
> ThreadSanitizer (<a href="http://clang.llvm.org/docs/ThreadSanitizer.html" target="_blank" class="cremed">http://clang.llvm.org/docs/ThreadSanitizer.html</a>)<br>
> and MemorySanitizer (<a href="http://clang.llvm.org/docs/MemorySanitizer.html" target="_blank" class="cremed">http://clang.llvm.org/docs/MemorySanitizer.html</a>)<br>
><br>
> For MemorySanitizer I propose __attribute__((no_uninitialized_checks))<br>
> Objections? Better naming suggestion?<br>
> Maybe __attribute__((no_memory_sanitizer))?<br>
> (We deliberately named no-asan attribute "no_address_safety_analysis" w/o<br>
> mentioning asan<br>
> in the name to make this attribute usable for other tools, e.g. SAFECode.<br>
> So,<br>
> we may not want to tie the no-msan attribute to msan)<br>
<br>
</div>It seems to me like it is going to be simpler and more transparent to<br>
have the attribute explicitly mention the sanitizer, e.g.`<br>
__attribute__((no_sanitize("memory")))`; then the user knows exactly<br>
what they are getting (since the name corresponds with the command<br>
line option). If other tools want to use those attributes it's not<br>
hard to look for them.<br>
<br>
It also isn't entirely clear to me that the attribute would have<br>
exactly the same semantics for the sanitizers and some other tool.<br>
AFAIK the term "address safety" has no independent meaning and<br>
basically means "the things that asan checks", so the term "address"<br>
in `__attribute__((no_address_safety_analysis))` is already asan<br>
specific in that regard, and it would be clearer to just say<br>
`no_sanitize("memory")`.<br>
<br>
If we really want the attributes to be tool-agnostic, then they should<br>
describe what the function does that is naughty, e.g.<br>
`__attribute__((reads_unintialized_memory_on_purpose))`, and let the<br>
tool interpret that information and behave appropriately.<br></blockquote><div><br></div><div style>This summarizes my feelings exactly.</div><div style><br></div><div style>I think that even if we grow a set of attributes that describe the semantic oddity of a function (such as reading uninitialized memory, etc), we would still want an escape hatch to just turn off the sanitizer. And when we do that, we really do want to use the exact same terminology that we use in the flags.</div>
<div style><br></div><div style>I don't think it matters whether its one attribute or N attributes as long as we get some naming consistency. I would propose (for simplicity of implementation mostly):</div><div style>
<br></div><div style>__attribute__((no_sanitize_address))<br></div><div style>__attribute__((no_sanitize_memory))<br></div><div style><div>__attribute__((no_sanitize_thread))<br></div><div style>__attribute__((no_sanitize_undefined))</div>
<div style>...</div><div style><br></div><div style>This pattern should be easy to remember and understand, and removes a lot of ambiguity of which attribute goes with which sanitizer. It also makes it very clear that these are attributes pertaining to the dynamic analysis toolset, not to any static analysis toolset.</div>
<div style><br></div><div style>Of course, I think we should support the existing attributes for backwards compatibility, at least for several releases.</div></div></div></div></div>