public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/111009] New: [12/13/14 regression] -fno-strict-overflow erroneously elides null pointer checks and causes SIGSEGV on perf from linux-6.4.10
@ 2023-08-14  8:26 slyfox at gcc dot gnu.org
  2023-08-14  9:34 ` [Bug middle-end/111009] " amonakov at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: slyfox at gcc dot gnu.org @ 2023-08-14  8:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111009
           Summary: [12/13/14 regression] -fno-strict-overflow erroneously
                    elides null pointer checks and causes SIGSEGV on perf
                    from linux-6.4.10
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
  Target Milestone: ---

Initially observed the failure as a perf SIGSEGV when running against
r14-3191-g614052dd4ea083.

I hope I did not break it too much when minimizing. Self-contained example:

// $ cat bug c.c
struct dso {
 struct dso * next;
 int maj;
};

__attribute__((noipa)) static void __dso_id__cmp_(void) {}

__attribute__((noipa))
static int bug(struct dso * d, struct dso *dso)
{
 struct dso **p = &d;
 struct dso *curr = 0;

 while (*p) {
  curr = *p;
  // prevent null deref below
  if (!dso) return 1;
  if (dso == curr) return 1;

  int *a = &dso->maj;
  // null deref
  if (!(a && *a)) __dso_id__cmp_();

  p = &curr->next;
 }
 return 0;
}

__attribute__((noipa))
int main(void) {
    struct dso d = { 0, 0, };
    bug(&d, 0);
}

Triggering the bug:

$ gcc -fno-strict-overflow -O3 bug.c.c -o bug3 && ./bug3
Segmentation fault (core dumped)

$ gcc -fno-strict-overflow -O2 bug.c.c -o bug2 && ./bug2
<ok>

$ gcc -v
Using built-in specs.
COLLECT_GCC=/<<NIX>>/gcc-14.0.0/bin/gcc
COLLECT_LTO_WRAPPER=/<<NIX>>/gcc-14.0.0/libexec/gcc/x86_64-unknown-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../source/configure --prefix=/<<NIX>>/gcc-14.0.0
--with-gmp-include=/<<NIX>>/gmp-6.3.0-dev/include
--with-gmp-lib=/<<NIX>>/gmp-6.3.0/lib
--with-mpfr-include=/<<NIX>>/mpfr-4.2.0-12-dev/include
--with-mpfr-lib=/<<NIX>>/mpfr-4.2.0-12/lib --with-mpc=/<<NIX>>/libmpc-1.3.1
--with-native-system-header-dir=/<<NIX>>/glibc-2.38-dev/include
--with-build-sysroot=/ --program-prefix= --enable-lto --disable-libstdcxx-pch
--without-included-gettext --with-system-zlib --enable-checking=release
--enable-static --enable-languages=c,c++ --disable-multilib --enable-plugin
--disable-libcc1 --with-isl=/<<NIX>>/isl-0.20 --disable-bootstrap
--build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu
--target=x86_64-unknown-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 99999999 (experimental) (GCC)

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

end of thread, other threads:[~2024-06-12 11:38 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-14  8:26 [Bug middle-end/111009] New: [12/13/14 regression] -fno-strict-overflow erroneously elides null pointer checks and causes SIGSEGV on perf from linux-6.4.10 slyfox at gcc dot gnu.org
2023-08-14  9:34 ` [Bug middle-end/111009] " amonakov at gcc dot gnu.org
2023-08-14 11:34 ` rguenth at gcc dot gnu.org
2023-08-14 11:48 ` rguenth at gcc dot gnu.org
2023-08-15 17:57 ` amacleod at redhat dot com
2023-08-16 20:14 ` slyfox at gcc dot gnu.org
2023-08-16 20:21 ` sjames at gcc dot gnu.org
2023-08-16 20:40 ` slyfox at gcc dot gnu.org
2023-08-16 21:05 ` amacleod at redhat dot com
2023-08-16 21:24 ` slyfox at gcc dot gnu.org
2023-08-17 15:37 ` amacleod at redhat dot com
2023-08-17 17:39 ` cvs-commit at gcc dot gnu.org
2023-08-17 19:44 ` slyfox at gcc dot gnu.org
2024-05-08 12:03 ` [Bug middle-end/111009] [12/13 " rguenth at gcc dot gnu.org
2024-05-08 18:26 ` amacleod at redhat dot com
2024-05-09 14:32 ` cvs-commit at gcc dot gnu.org
2024-05-10  6:36 ` [Bug middle-end/111009] [12 " rguenth at gcc dot gnu.org
2024-05-13 17:49 ` cvs-commit at gcc dot gnu.org
2024-06-12 11:38 ` 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).