public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/96304] New: Possible mis-compile of SQLite for ARM using gcc 8.3.0 and -O2
@ 2020-07-23 21:15 drh at sqlite dot org
  2020-07-23 21:17 ` [Bug target/96304] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: drh at sqlite dot org @ 2020-07-23 21:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96304
           Summary: Possible mis-compile of SQLite for ARM using gcc 8.3.0
                    and -O2
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: drh at sqlite dot org
  Target Milestone: ---

Gcc 8.3.0 appears to be miscompiling SQLite for ARM when using -O2. A correct
build occurs with any other optimization setting, on X86_64, and with versions
of gcc in the 4.x.x timeframe (the only other versions tested).  The bug
originates from two Gentoo bug reports against SQLite that claim the problem
also appears on PPC and SPARC, but I do not have appropriate hardware at hand
to verify that.

Unfortunately, I do not have a concise test case for you.  However, I can
demonstrate the problem using one large C source file and one data file, as
described here: https://sqlite.org/forum/forumpost/c3e9c0edfa

We can work around the problem in SQLite by marking one particular function
using __attribute__((noinline)). You can see our work-around here:
https://www.sqlite.org/src/info/40c44d38104dfcb6

The forum post in the first link describes how to recreate the problem. I will
repeat that text here for completeness:

  1.  Download https://sqlite.org/tmp/gcc-problem-20200723/sftest.c (7.8MB) and
https://sqlite.org/tmp/gcc-problem-20200723/data1.db (252KB).
  2.  Compile using: "$GCC -O2 sftest.c"
  3.  Run like this: "./a.out run data1.db"

The expected output is "d1.db:  339 cases, 0 crashes" but the program hits an
assert() when compiled for ARM using -O2 using more recent versions of gcc
(newer than the 4.9.2 version that is the default on my raspberry PI). 
Additional analysis of the problem is in the forum post and the check-in linked
above.

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

end of thread, other threads:[~2020-07-24  8:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-23 21:15 [Bug c/96304] New: Possible mis-compile of SQLite for ARM using gcc 8.3.0 and -O2 drh at sqlite dot org
2020-07-23 21:17 ` [Bug target/96304] " pinskia at gcc dot gnu.org
2020-07-23 21:24 ` drh at sqlite dot org
2020-07-24  6:53 ` marxin at gcc dot gnu.org
2020-07-24  7:10 ` rguenth at gcc dot gnu.org
2020-07-24  8:32 ` drh at sqlite dot org
2020-07-24  8:47 ` marxin 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).