From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CD7CE385703C; Mon, 8 Aug 2022 21:20:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD7CE385703C From: "noloader at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106568] New: -freorder-blocks-algorithm appears to causes a crash in stable code, no way to disable it Date: Mon, 08 Aug 2022 21:20:53 +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: 12.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: noloader at gmail dot com 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: Mon, 08 Aug 2022 21:20:53 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106568 Bug ID: 106568 Summary: -freorder-blocks-algorithm appears to causes a crash in stable code, no way to disable it Product: gcc Version: 12.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: noloader at gmail dot com Target Milestone: --- Hi Everyone, This is going to be a shitty bug report because we don't have a reproducer.= We believe we have it narrowed down to a particular optimization, however. Debian Unstable, Fedora 37 and Gentoo 17.1 are reporting crashes in Crypto++ test program.[1,2] The distros use GCC 12. We found a particular function crashes without explanation (and a garbage backtrace) at -O2 and -O3. The function is Ok at -O0, -O1 and -Os. (The code has been fairly stable for years. It is -Wall, -Wextra, Asan, UBs= an and Valgrind clean. We would be surprised to learn we have undetected UB. B= ut we don't rule it out). According to GCC Optimization docs, the difference between -Os (no crash) a= nd -O2 (crash) are:[3] -falign-functions -falign-jumps -falign-labels -falign-loops -fprefetch-loop-arrays -freorder-blocks-algorithm=3Dstc We used CFLAGS and CXXFLAGS with -Os plus listed opts less -freorder-blocks-algorithm=3Dstc. The crash went away. We are fairly certain the problem is with the -freorder-blocks-algorithm optimization. The problem we are now having is, we don't know how to disable it. The following fails to compile: -fno-reorder-blocks-algorithm -freorder-blocks-algorithm=3Dnone -freorder-blocks-algorithm=3D So, we believe we have a bad option in -freorder-blocks-algorithm, but we c= an't disable it for typical opt settings used by distros. The typical opt settin= g is -O2 or -O3. I sincerely apologize for not having a reproducer. I'm not sure where to be= gin when it comes to -freorder-blocks-algorithm. Please advise. [1] https://github.com/weidai11/cryptopp/issues/1134 [2] https://github.com/weidai11/cryptopp/issues/1141 [3] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html=