From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 436353945E06; Thu, 8 Dec 2022 15:11:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 436353945E06 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670512289; bh=POHOMr9iyzfmIY9e8P11PMQfHVh4rJfp3+RLGYTYb1s=; h=From:To:Subject:Date:From; b=OJB24hWAFXqWQuBDxmG9ZsnClEMxkR7H4rxmK8FNUW0KoHnNPND5LabRpOnThwZIM mlWQ+nEFtPelF0GfShAK4C3ZigHedX7BlmHDhShIg3jVoyhoQR7G3Nhxv1Fesu0oEo EyAUggBQY4lMhmn5tQLYIfa1a0kV0Rb+M+xbn/tc= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/108023] New: Incorrect line number in ASAN's report Date: Thu, 08 Dec 2022 15:11:28 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: shaohua.li at inf dot ethz.ch X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108023 Bug ID: 108023 Summary: Incorrect line number in ASAN's report 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, marxi= n at gcc dot gnu.org Target Milestone: --- For the following code, GCC's ASAN at -O1 and above produce incorrect line numbers in the final reports (Line 15 v.s. Line 8). Compiler explorer: https://godbolt.org/z/4953EPr78 % cat a.c int a, b, c, g, f; static long d(int); long d(int h) { int **j =3D (int**)malloc(sizeof(int *) * sizeof(int)); for (int i =3D 0; i < sizeof(int); i++) j[i] =3D malloc(sizeof(f)); int *k =3D malloc(sizeof(int) * sizeof(g)); for (h=3D0; h <=3D 2; h++) { free(k); for (b=3D0; b <=3D 2; b++) k[3] =3D j[0][h]; } return k[a]; } void e() {=20 c =3D d(0);=20 } int main() {=20 e();=20=20 return c; } % % gcc-tk -O0 -fsanitize=3Daddress -w -g a.c && ./a.out =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D3175968=3D=3DERROR: AddressSanitizer: heap-use-after-free on address 0x60200000009c at pc 0x00000040130f bp 0x7ffd47fc9fd0 sp 0x7ffd47fc9fc8 WRITE of size 4 at 0x60200000009c thread T0 #0 0x40130e in d /a.c:15 #1 0x4013a3 in e /a.c:21 #2 0x4013ba in main /a.c:25 ... % % gcc-tk -O2 -fsanitize=3Daddress -w -g a.c && ./a.out =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D3254785=3D=3DERROR: AddressSanitizer: heap-use-after-free on address 0x60200000009c at pc 0x000000401354 bp 0x7ffce8fa2e80 sp 0x7ffce8fa2e78 WRITE of size 4 at 0x60200000009c thread T0 #0 0x401353 in d /a.c:8 #1 0x4010e8 in e /a.c:21 #2 0x4010e8 in main /a.c:25 ... %=