From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3F5833858D35; Tue, 16 Nov 2021 13:12:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F5833858D35 From: "tomas.kalibera at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/103274] New: Remaining -freorder-blocks-and-partition/ glitch with Windows SEH Date: Tue, 16 Nov 2021 13:12:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tomas.kalibera 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 attachments.created 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: Tue, 16 Nov 2021 13:12:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103274 Bug ID: 103274 Summary: Remaining -freorder-blocks-and-partition/ glitch with Windows SEH Product: gcc Version: 10.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: tomas.kalibera at gmail dot com Target Milestone: --- Created attachment 51809 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D51809&action=3Dedit When compiled with -O3, dummy ends in a call (invalid unwind information). -freorder-blocks-and-partition sometimes causes a function to end right in a (non-returning) call, but SEH needs at least one more instruction on x86_64. Seen in GCC 10.3, 11.2 and git master. Maybe [1] did not cover all the case= s? The attached compile-only example compiled with -O3 reproduces the problem.= It is extracted from R, where this problem causes crashes (and where in wine, = one gets an error "virtual_unwind exception data not found" and further instrumentation reveals it is because the address following the call instruction is already at the function boundary). The problem can be seen directly from the assembly: gcc -O3 -c -S ../main/a.c -o - produces dummy: [...] .L5: call myerrorcall .seh_endproc [...] dummy.cold: For reference, R is affected by this and has been disabling SEH as a workaround, but it has been reported that the workaround causes in turns crashes with CFG. This report is with substantial help from Martin Storsjo. =3D=3D=3D=3D=3D=3D=3D [1] https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dcommitdiff;h=3D15278fb2877184c75a6= ee3a6def09efbb191968b;hp=3D9d3b9a3e70e634c7c48bb12bb35ec8219024f98b [2] https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dblob;f=3Dgcc/config/i386/i386.c;h= =3D1bca5a7eea6ab9accbbf6953f79e8a4da61859e2;hb=3D4212a6a3e44f870412d9025eeb= 323fd4f50a61da#l29076 [3] https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/X86/X86Avoid= TrailingCall.cpp [4] https://bugs.r-project.org/show_bug.cgi?id=3D18180=