https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107752
Bug ID: 107752 Summary: Lack of offset information in AddressSanitizer reports Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch 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, I found that GCC's ASAN reports do not include offset information, while Clang's ASAN does. Both GCC's UBSan and Clang'UBSan include offset information. For example, for the following code, % cat a.c int main() { int a[1] = {0}; return a[1]; } % GCC's ASAN report only includes the line numbers of the stack trace (a.c:3): ``` ================================================================= ==1842608==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff7181ea14 at pc 0x55f5214542e2 bp 0x7fff7181e9e0 sp 0x7fff7181e9d0 READ of size 4 at 0x7fff7181ea14 thread T0 #0 0x55f5214542e1 in main /home/shaoli/tmp/a.c:3 ... ``` Clang's ASAN report includes both the line numbers and offsets of the stack trace (a.c:3:10): ``` ================================================================= ==1910102==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffd53e4fa64 at pc 0x55a977f71884 bp 0x7ffd53e4fa30 sp 0x7ffd53e4fa28 READ of size 4 at 0x7ffd53e4fa64 thread T0 #0 0x55a977f71883 in main /home/shaoli/tmp/a.c:3:10 ``` Both GCC's and Clang's UBsans include all information: ``` a.c:3:11: runtime error: index 1 out of bounds for type 'int [1]' a.c:3:11: runtime error: load of address 0x7ffd420a6538 with insufficient space for an object of type 'int' ``` I believe it would be nice to include the offset information as it is very useful for users to quickly locate bugs in their code.