[cfe-dev] Question about __asan_set_error_report_callback

Kostya Serebryany kcc at google.com
Wed Mar 26 07:41:15 PDT 2014


On Wed, Mar 26, 2014 at 6:06 PM, Oliver Schneider <oliver at f-prot.com> wrote:

> Hi Kostya,
>
> thanks for your response.
>
> On 2014-03-26 11:27, Kostya Serebryany wrote:
> > Bad idea. asan reports serious bugs. If you suppress the first bug
> > report and go further
> > your process is already corrupted.
> Wait, I'm confused. Let me give you an example.
>
> -------------------
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <stdint.h>
>
> int main(int argc, char** argv)
> {
>     size_t i;
>     uint32_t buf[13];
>     const size_t bufct = sizeof(buf)/sizeof(buf[0]);
>     const uint8_t* bbuf = (uint8_t*)buf;
>
>     setbuf(stdout, NULL); /* no stdio buffering */
>     for(i = 0; i < sizeof(buf)/sizeof(buf[0]); i++)
>         buf[i] = 0xAABBCCDD;
>     /* provoke an error during the last iteration */
>     for(i = 0; i < sizeof(buf); i++)
>         /* type coercion provokes misaligned read */
>         printf("%08X\n", *((uint32_t*)&bbuf[i]));
>     return 0;
> }
> -------------------
>
> The error I would like to see is that the last iterations read the
> buffer beyond its limits. The one I get to see before - and which I'd
> like to filter - is the one reading:
>
> asan.c:19:20: runtime error: load of misaligned address ...
>

This is an error coming from -fsanitize=undefined, just drop this flag.


>
> It's this one about the misaligned address that I'd like to filter for now.
>
> I named the above source file asan.c and compiled with this:
>
> clang -O1 -fno-omit-frame-pointer -fsanitize=undefined
> -fstack-protector-all -fno-optimize-sibling-calls -fsanitize=address
> -fcolor-diagnostics -fno-limit-debug-info -g -fno-strict-aliasing
> -Wno-gcc-compat -o asan asan.c
>
> (unfortunately the line will be broken)
>
>
> // Oliver
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140326/38b8e3ed/attachment.html>


More information about the cfe-dev mailing list