From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 03D4E3858C50; Tue, 28 Feb 2023 08:57:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03D4E3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677574641; bh=xYAaXay5inuqAtXcIciWM/VbobXI1IR0DpBkb+r6FjI=; h=From:To:Subject:Date:From; b=GWcPKF+lImAGk4idq9Vsp02V7DvteXkKdas7ZiBrVgTFZicDJmpylSa5If46AXTxV LXxAvCIackLzdSU6q9q0vlUAWlukDjgdbmg55wQToCzbThSTApBH7bRbaEqXbAvqhY V1vFL8U4SHLgWW8S+bPmisv1JprZFdPin8QOyyyM= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/108963] New: ASAN produces wrong line number in the report Date: Tue, 28 Feb 2023 08:57:20 +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=3D108963 Bug ID: 108963 Summary: ASAN produces wrong line number in the 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, ASAN at -O1 and above always produces the wrong line number. I've found quite some cases that have this issue. Compiler explorer: https://godbolt.org/z/hscP9T78M % cat a.c union a { int b; }; char c; int d; static long e(int *f) { for (; c <=3D 1;c++) *(f + 1) |=3D 2; return 0; } int main() { union a g =3D {}; e(&d); &g; } % % gcc-tk -O0 -fsanitize=3Daddress 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=3D1=3D=3DERROR: AddressSanitizer: global-buffer-overflow on address 0x0= 00000404184 at pc 0x0000004011d6 bp 0x7ffea18cbe60 sp 0x7ffea18cbe58 READ of size 4 at 0x000000404184 thread T0 #0 0x4011d5 in e /a.c:8 #1 0x4012f1 in main /a.c:13 ... %=20 % gcc-tk -O1 -fsanitize=3Daddress 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=3D1=3D=3DERROR: AddressSanitizer: global-buffer-overflow on address 0x0= 00000404144 at pc 0x000000401289 bp 0x7ffff4114850 sp 0x7ffff4114848 READ of size 4 at 0x000000404144 thread T0 #0 0x401288 in main /a.c:12 ... % Maybe a fundunmentally similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108023=