From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E3551385B19B; Fri, 25 Nov 2022 09:32:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3551385B19B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669368757; bh=kfP0vYP58G5KSNCzvtuLAjY5/yPTXowHbOwEiuaoQpg=; h=From:To:Subject:Date:From; b=ZFlnnTR9I++5k26ODMt75UiJKIcpHF67BKb3EeEwM+FfKq5b40Q4AE9Uyys+3SIQF e1bb00jNCvnvY0q1LpEG6KCYyf4m3lnTLFxW6hc0K8FtM+kZt+qb6VMQm/xw2C84ST VB2yp7L+kdCINEalQ0zFTnX6kqDlWvfNPoGtABg4= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/107866] New: gcc trunk's UBSan misses a Nll-pointer-dereference at -O3. Date: Fri, 25 Nov 2022 09:32:37 +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=3D107866 Bug ID: 107866 Summary: gcc trunk's UBSan misses a Nll-pointer-dereference at -O3. 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-trunk -O3 -fsanitize=3Dundefined` misses the NULL-pointer-dereference, while `gcc-trunk -Ox -fsanitize=3Daddress` (x=3D0= ,1, 2, s) can detect it. gcc-12 has the same issue. gcc-11 can detect the bug at all optimization levels. clang can also detect it at all optimization levels. Compiler explorer: https://godbolt.org/z/WhrzP6zdf % cat a.c int *a; void main() { for (;;) { a =3D 0; if (*a) break; } } % % gcc-tk -O3 -fsanitize=3Dundefined -fno-sanitize-recover=3Dall a.c &&./a.o= ut Segmentation fault % gcc-tk -O2 -fsanitize=3Dundefined -fno-sanitize-recover=3Dall a.c &&./a.o= ut a.c:5:9: runtime error: load of null pointer of type 'int' %=