Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ramosian-glider opened this issue Aug 31, 2015 · 2 comments

Comments

@ramosian-glider
Copy link
Member

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
Copy link
Member Author

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

  • Status changed: WontFix

@ramosian-glider
Copy link
Member Author

Adding Project:AddressSanitizer as part of GitHub migration.

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

  • Labels added: ProjectAddressSanitizer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant