public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/107866] New: gcc trunk's UBSan  misses a Nll-pointer-dereference at -O3.
@ 2022-11-25  9:32 shaohua.li at inf dot ethz.ch
  2022-11-25 10:40 ` [Bug sanitizer/107866] [12/13 Regression] gcc trunk's UBSan misses a Null-pointer-dereference " jakub at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2022-11-25  9:32 UTC (permalink / raw)
  To: gcc-bugs

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

            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, marxin at gcc dot gnu.org
  Target Milestone: ---

For the following code, `gcc-trunk -O3 -fsanitize=undefined` misses the
NULL-pointer-dereference, while `gcc-trunk -Ox -fsanitize=address` (x=0,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 = 0;
    if (*a)
      break;
  }
}
%
% gcc-tk -O3 -fsanitize=undefined -fno-sanitize-recover=all a.c &&./a.out
Segmentation fault
% gcc-tk -O2 -fsanitize=undefined -fno-sanitize-recover=all a.c &&./a.out
a.c:5:9: runtime error: load of null pointer of type 'int'
%

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-05-08 12:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25  9:32 [Bug sanitizer/107866] New: gcc trunk's UBSan misses a Nll-pointer-dereference at -O3 shaohua.li at inf dot ethz.ch
2022-11-25 10:40 ` [Bug sanitizer/107866] [12/13 Regression] gcc trunk's UBSan misses a Null-pointer-dereference " jakub at gcc dot gnu.org
2022-11-25 10:56 ` shaohua.li at inf dot ethz.ch
2022-11-25 12:20 ` marxin at gcc dot gnu.org
2022-11-25 12:36 ` rguenth at gcc dot gnu.org
2023-05-08 12:26 ` [Bug sanitizer/107866] [12/13/14 " rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).