public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/108994] [13 Regression] LLVM JIT segfaults in libgcc after upgrading from gcc 12.2.1 to 13.0.1 since r13-2706-g6e80a1d164d1f9
Date: Tue, 14 Mar 2023 07:04:55 +0000	[thread overview]
Message-ID: <bug-108994-4-htmjDvBW4c@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108994-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
It is a fundamental assumption that the FDE/CIE chain is zero terminated, after
all, all the registration APIs (__register_frame_table,
__register_frame_info_table, __register_frame_info_table_bases) take just a
begin pointer, not a begin and end pointer nor begin + count or something
similar, nor assume there is just one FDE (after all, a FDE needs some CIE, so
there would need to be a routine that expects exactly two or something
similar).

When not using .eh_frame_hdr (which is used most of the time on glibc since end
of 2001 when I've added it and somewhat later on Solaris etc.),
crtbegin.o/crtend.o ensures this, crtbegin.o provides a label at the start of
.eh_frame and is linked first among the objects:
/* Stick a label at the beginning of the frame unwind info so we can register
   and deregister it with the exception handling library code.  */
STATIC EH_FRAME_SECTION_CONST char __EH_FRAME_BEGIN__[]
     __attribute__((section(__LIBGCC_EH_FRAME_SECTION_NAME__), aligned(4)))
     = { };
while crtend.o provides the zero termination:
/* Terminate the frame unwind info section with a 4byte 0 as a sentinel;
   this would be the 'length' field in a real FDE.  */
# if __INT_MAX__ == 2147483647
typedef int int32;
# elif __LONG_MAX__ == 2147483647
typedef long int32;
# elif __SHRT_MAX__ == 2147483647
typedef short int32;
# else
#  error "Missing a 4 byte integer"
# endif
STATIC EH_FRAME_SECTION_CONST int32 __FRAME_END__[]
     __attribute__ ((used, section(__LIBGCC_EH_FRAME_SECTION_NAME__),
                     aligned(__alignof__(int32))))
     = { 0 };
and is linked last.
I believe LLVM does the same thing in compiler-rt/lib/crt/crtbegin.c and
compiler-rt/lib/crt/crtend.c .
If you readelf -wf any_binary_or_library
it should show
00330010 ZERO terminator
line (with whatever address) at the end.

  parent reply	other threads:[~2023-03-14  7:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-02 18:15 [Bug libgcc/108994] New: LLVM JIT segfaults in libgcc after upgrading from gcc 12.2.1 to 13.0.1 tstellar at redhat dot com
2023-03-02 18:19 ` [Bug libgcc/108994] [13 Regression] " redi at gcc dot gnu.org
2023-03-02 19:15 ` pinskia at gcc dot gnu.org
2023-03-02 19:19 ` tstellar at redhat dot com
2023-03-02 20:09 ` pinskia at gcc dot gnu.org
2023-03-03  3:13 ` tstellar at redhat dot com
2023-03-03  3:29 ` pinskia at gcc dot gnu.org
2023-03-03  7:39 ` tstellar at redhat dot com
2023-03-03  7:45 ` pinskia at gcc dot gnu.org
2023-03-03  7:46 ` pinskia at gcc dot gnu.org
2023-03-03  7:47 ` redi at gcc dot gnu.org
2023-03-03  8:45 ` [Bug target/108994] " jakub at gcc dot gnu.org
2023-03-03 18:37 ` tstellar at redhat dot com
2023-03-04  0:15 ` tstellar at redhat dot com
2023-03-06 12:37 ` [Bug target/108994] [13 Regression] LLVM JIT segfaults in libgcc after upgrading from gcc 12.2.1 to 13.0.1 since r13-2706-g6e80a1d164d1f9 marxin at gcc dot gnu.org
2023-03-09 16:29 ` tstellar at redhat dot com
2023-03-09 18:50 ` tstellar at redhat dot com
2023-03-10 17:18 ` jakub at gcc dot gnu.org
2023-03-10 17:37 ` tstellar at redhat dot com
2023-03-14  5:41 ` tstellar at redhat dot com
2023-03-14  7:04 ` jakub at gcc dot gnu.org [this message]
2023-03-14 17:22 ` tstellar at redhat dot com
2023-03-14 18:08 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108994-4-htmjDvBW4c@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).