[Bug sanitizer/89298] Address-Sanitizer false positive for global-buffer-overflow?

lee_shao at 126 dot com gcc-bugzilla@gcc.gnu.org
Tue Feb 12 09:29:00 GMT 2019


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

--- Comment #3 from Keerecles <lee_shao at 126 dot com> ---
(In reply to Jakub Jelinek from comment #2)
> It is not clear how that can compile, because both
> unsigned int g_var =0;
> and
> extern unsigned int g_var =0;
> are g_var definitions, so if that is in multiple TUs, linker should fail to
> link that.
No multiple definitions and the program is successfully compiled and linked.

> In the other snippet you mention
> int g_var_a;
> which is something very different (unless -fno-common), that is a common var
> and ASAN doesn't instrument those.

Sorry, I made a mistake. In my application, ASAN reports global-buffer-overflow
just on the global g_var. 
"int g_var_a;"  should be "int g_var;"



Here is the ASAN log :
 $ LD_PRELOAD=/usr/local/gcc-8.1/lib/libasan.so gdb ./App
 $ b ***/***/AAA.c:288
 $ run
 $ Breakpoint 1  288 g_var=1;
 $ p &g_var  
 $ $1 = (int) 0xe04e4620 <g_var>
 $ n
 $ ==106196==ERROR: AddressSanitizer: global-buffer-overflow on address
0x08d09bc0 at pc 0xde57b983 bp 0xffffcfe8 sp 0xffffcfdc [Here the address
(0x08d09bc0) is not 0xe04e4620 ]
 $ #0 0xde57b982 in  ***/***/AAA.c:288
 $ 0x08d09bc0 is located 0 bytes to the right of global variable 'g_var_others'
defined in ***
 $ 0x08d09bc0 is located 0 bytes inside of global variable 'g_var' defined in 
***


More information about the Gcc-bugs mailing list