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

            Bug ID: 89323
           Summary: Asan memory leak detection on x86 platform
           Product: gcc
           Version: 6.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ganeshemb at gmail dot com
                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: ---

Hi,

Asan memory leak detection does not seem to on x86 platform.

Sample C program with memory leak

cat asantest.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main (int argc, char *argv[])
{
    char *name = (char*) malloc(10);
    strcpy(name, argv[1]);
    printf("Hello, %s!\n", name);
    return 0;
}


`gcc -g -m32 -fsanitize=address -fno-omit-frame-pointer asantest.c -o santest`

```
objdump -a asantest

asantest:     file format elf32-i386
```
```
 ldd asantest
        linux-gate.so.1 (0xf778a000)
        libasan.so.3 => /usr/lib32/libasan.so.3 (0xf71e0000)
```
```
gcc --version
gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 
```
when program run as shown below , no leaks were detected.

```
./asantest world
Hello, world!
```
when program run with ASAN_OPTIONS , following error is shown.

```
ASAN_OPTIONS=detect_leaks=1 ./asantest world
==8192==AddressSanitizer: detect_leaks is not supported on this platform.
```
My system info

```
 lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
```
```
uname -r
4.9.0-8-amd64
```

works for current clang:

clang-6.0 -g -fsanitize=address -fno-omit-frame-pointer -m32  asantest.c  &&
./a.out 

AddressSanitizer:DEADLYSIGNAL
=================================================================
==6318==ERROR: AddressSanitizer: SEGV on unknown address 0x00000000 (pc
0xf74f2a66 bp 0xfff26cb8 sp 0xfff26854 T0)



Thanks in advance.

Reply via email to