[cfe-dev] Question about __asan_set_error_report_callback

Oliver Schneider oliver at f-prot.com
Wed Mar 26 07:06:37 PDT 2014


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 ...

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 --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 553 bytes
Desc: OpenPGP digital signature
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140326/085de647/attachment.sig>


More information about the cfe-dev mailing list