public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/103274] New: Remaining -freorder-blocks-and-partition/ glitch with Windows SEH
@ 2021-11-16 13:12 tomas.kalibera at gmail dot com
  2021-11-16 14:55 ` [Bug target/103274] " ebotcazou at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: tomas.kalibera at gmail dot com @ 2021-11-16 13:12 UTC (permalink / raw)
  To: gcc-bugs

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

            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=51809&action=edit
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 cases?

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.

=======

[1]
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=15278fb2877184c75a6ee3a6def09efbb191968b;hp=9d3b9a3e70e634c7c48bb12bb35ec8219024f98b

[2]
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/i386/i386.c;h=1bca5a7eea6ab9accbbf6953f79e8a4da61859e2;hb=4212a6a3e44f870412d9025eeb323fd4f50a61da#l29076

[3]
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/X86/X86AvoidTrailingCall.cpp

[4] https://bugs.r-project.org/show_bug.cgi?id=18180

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

end of thread, other threads:[~2021-12-01 22:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 13:12 [Bug target/103274] New: Remaining -freorder-blocks-and-partition/ glitch with Windows SEH tomas.kalibera at gmail dot com
2021-11-16 14:55 ` [Bug target/103274] " ebotcazou at gcc dot gnu.org
2021-11-16 15:27 ` tomas.kalibera at gmail dot com
2021-11-16 16:02 ` martin at martin dot st
2021-11-16 16:07 ` martin at martin dot st
2021-11-16 17:11 ` [Bug target/103274] [10/11/12 regression] remaining " ebotcazou at gcc dot gnu.org
2021-11-16 17:34 ` ebotcazou at gcc dot gnu.org
2021-11-30  9:19 ` cvs-commit at gcc dot gnu.org
2021-11-30  9:21 ` cvs-commit at gcc dot gnu.org
2021-11-30  9:23 ` cvs-commit at gcc dot gnu.org
2021-11-30  9:24 ` ebotcazou at gcc dot gnu.org
2021-12-01  7:46 ` martin at martin dot st
2021-12-01 22:59 ` tomas.kalibera at gmail dot com

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).