ChokkaUoM / address-sanitizer

Automatically exported from code.google.com/p/address-sanitizer
0 stars 0 forks source link

No redzone created before first global #383

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
AddressSanitizer does not seem to create a redzone before the first global 
variable. Consider the following example:

int global1 = 123;
int global2 = 456;

int main()
{
    int v = *(&global1 - 1);
    return 0;
}

ASAN does not catch the invalid read because no readzone exists before global1. 
Reading from &global2 - 1 does trigger an ASAN error report. Is this expected 
behaviour? I build with Clang 3.5 on a Ubuntu 14.04 x64 installation: clang 
-fsanitize=address -g -O0 test.c

Thanks!

Original issue reported on code.google.com by chrhaus...@googlemail.com on 23 Mar 2015 at 6:56

GoogleCodeExporter commented 9 years ago
yes, this is known.
We do not plan any fix (no easy one is seen)

Original comment by konstant...@gmail.com on 23 Mar 2015 at 7:32

GoogleCodeExporter commented 9 years ago
Thanks for clarifying.

Original comment by chrhaus...@googlemail.com on 23 Mar 2015 at 7:37

GoogleCodeExporter commented 9 years ago
We can insert dummy globals in asan_preinit.o and build it with 
-fsanitize=address. This would only work for executables though.

Original comment by tetra20...@gmail.com on 24 Mar 2015 at 7:06

GoogleCodeExporter commented 9 years ago
I don't think there is any guarantee that globals from asan_preinit.o will 
appear at the start of .bss/.data.

Original comment by euge...@google.com on 30 Mar 2015 at 10:51

GoogleCodeExporter commented 9 years ago
I thought linker arranges file data in the order they appear on cmdline.

Original comment by tetra20...@gmail.com on 30 Mar 2015 at 11:00

GoogleCodeExporter commented 9 years ago
With -fdata-sections and linker GC it may not be as simple as that.
But I guess in most cases (if not always, with the _current_ linker 
implementation) it will be at the start of the output section. In any case, a 
dummy global won't hurt.

Original comment by euge...@google.com on 30 Mar 2015 at 11:04

GoogleCodeExporter commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Original comment by ramosian.glider@gmail.com on 30 Jul 2015 at 9:06