https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85389

            Bug ID: 85389
           Summary: posix_memalign() crash with address sanitizer when
                    passing invalid arguments
           Product: gcc
           Version: 6.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabriel.ganne at mindmaze dot ch
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at 
gcc dot gnu.org
  Target Milestone: ---

Created attachment 43924
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43924&action=edit
posix_memalign() test

Hi,

exact gcc version is : gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516

The attached file tests posix_memalign() with an invalid alignment of 1.
The expected behavior is for posix_memalign() to return EINVAL and to leave
memptr untouched, or to set it to NULL.

This works as expected *without* address sanitizer, but fails when enabled :

$ gcc  posix-memalign.c ;  ./a.out
rv = 22
ptr = 0xffffffffffffffff

$ gcc -fsanitize=address posix-memalign.c && ./a.out                            
ASAN:DEADLYSIGNAL
=================================================================
==2682==ERROR: AddressSanitizer: SEGV on unknown address 0xffffffffffffffff (pc
0x7f16dbe25fb3 bp 0xffffffffffffffff sp 0x7ffc4a3c0150 T0)
    #0 0x7f16dbe25fb2  (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x23fb2)
    #1 0x7f16dbec473d in posix_memalign
(/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc273d)
    #2 0x5625796e7bd5 in main (/tmp/posix_memalign/a.out+0xbd5)
    #3 0x7f16dba832e0 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #4 0x5625796e7aa9 in _start (/tmp/posix_memalign/a.out+0xaa9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV
(/usr/lib/x86_64-linux-gnu/libasan.so.3+0x23fb2)
==2682==ABORTING

Reply via email to