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
          Reporter: gabriel.ganne at mindmaze dot ch
                CC: dodji at gcc dot, dvyukov at gcc dot,
                    jakub at gcc dot, kcc at gcc dot, marxin at 
gcc dot
  Target Milestone: ---

Created attachment 43924
posix_memalign() test


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                            
==2682==ERROR: AddressSanitizer: SEGV on unknown address 0xffffffffffffffff (pc
0x7f16dbe25fb3 bp 0xffffffffffffffff sp 0x7ffc4a3c0150 T0)
    #0 0x7f16dbe25fb2  (/usr/lib/x86_64-linux-gnu/
    #1 0x7f16dbec473d in posix_memalign
    #2 0x5625796e7bd5 in main (/tmp/posix_memalign/a.out+0xbd5)
    #3 0x7f16dba832e0 in __libc_start_main
    #4 0x5625796e7aa9 in _start (/tmp/posix_memalign/a.out+0xaa9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV

Reply via email to