ramosian-glider / sanitizer-issues

test
0 stars 0 forks source link

Unable to detect the Dangling pointer reference for the stacked variables... #71

Closed ramosian-glider closed 9 years ago

ramosian-glider commented 9 years ago

Originally reported on Google Code with ID 71

What steps will reproduce the problem?
1.[root@localhost samples]# cat test.c
int *ptr = (void *) 0;

void func()
{
 int a = 10;
 ptr = &a;
}

int main()
{
 func();
 return *ptr     //Dangling pointer reference.

}

2. clang  -g -faddress-sanitizer -fno-omit-frame-pointer -o test test.c
3../test

What is the expected output? What do you see instead?
Expected :
We See : 

What version of the product are you using? On what operating system?

[root@localhost opensrc]# clang --version
clang version 3.2 (trunk)
Target: i386-pc-linux-gnu
Thread model: posix

[root@localhost opensrc]# uname -a
Linux localhost.localdomain 2.6.32-220.el6.i686 #1 SMP Tue Dec 6 16:15:40 GMT 2011
i686 i686 i386 GNU/Linux
[root@localhost opensrc]# cat /etc/centos-release
CentOS release 6.2 (Final)

Reported by umesh.kalappa0 on 2012-05-15 06:56:44

ramosian-glider commented 9 years ago
By default, asan does not detect use-after-return. 
As mentioned at http://code.google.com/p/address-sanitizer/wiki/ExampleUseAfterReturn,

you need to use an additional build flag: -mllvm -asan-use-after-return.
With this flag I get a warning: 

==20526== ERROR: AddressSanitizer stack-use-after-return on address 0x7fe82beb3220
at pc 0x406a84 bp 0x7fffbf9f0550 sp 0x7fffbf9f0548
READ of size 4 at 0x7fe82beb3220 thread T0
    #0 0x406a84 (test+0x406a84)
    #1 0x7fe82c6d1c4d (/lib/libc-2.11.1.so+0x1ec4d)
Address 0x7fe82beb3220 is located at offset 32 in frame <func> of T0's stack:
  This frame has 1 object(s):
    [32, 36) 'a'

Note, that this mode is still experimental and not officially supported. 

Reported by konstantin.s.serebryany on 2012-05-15 07:02:43

ramosian-glider commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Reported by ramosian.glider on 2015-07-30 09:12:59