From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D9FA63938C00; Thu, 23 Jul 2020 21:15:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D9FA63938C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1595538958; bh=8RtMkolElS+9SSV6EdagOZboPtsx5ir/kJL9+XG5GX4=; h=From:To:Subject:Date:From; b=IQ+tZLN53RBJm915+qfjSLMa4IxmlIX6kqVkpiOH41e8fxAk9Mp1LpTT6bT2Mugwp 7sws83WmoXar9xMB7AwzpKlfxctsubsLdwCQ/7LpWnYa3zaw1Fxh0knuR4AsjyI1qI /dkj1taaUx/lJlZcV9Oqi/Ltmr45X5jT7G2QYJHA= From: "drh at sqlite dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/96304] New: Possible mis-compile of SQLite for ARM using gcc 8.3.0 and -O2 Date: Thu, 23 Jul 2020 21:15:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 8.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: drh at sqlite dot org 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 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jul 2020 21:15:59 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96304 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 corre= ct build occurs with any other optimization setting, on X86_64, and with versi= ons 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 ha= nd 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 w= ill 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).=20 Additional analysis of the problem is in the forum post and the check-in li= nked above.=