public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "d at ilvokhin dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/94972] New: Function multi-versioning binary may crash dynamic linker
Date: Wed, 06 May 2020 13:37:49 +0000	[thread overview]
Message-ID: <bug-94972-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 94972
           Summary: Function multi-versioning binary may crash dynamic
                    linker
           Product: gcc
           Version: 9.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: d at ilvokhin dot com
  Target Milestone: ---

Created attachment 48468
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48468&action=edit
Simplified version of function multi-versioning example

I compiled simple binary (a simplified version of function multi-versioning
example from gcc.gnu.org) and do ldd -u -r on result.

This leads to ldd segfault in __cpu_indicator_init from libgcc_s.so.

Behaviour is observed at least for GCC 9.1.1 and 7.3.1 (both from Red Hat
devtoolset).

$ g++ --version
g++ (GCC) 9.1.1 20190605 (Red Hat 9.1.1-2)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++ tt.cpp -o cpp
$ ldd -u -r ./cpp
/usr/bin/ldd: line 116:  6148 Segmentation fault      (core dumped)
LD_TRACE_LOADED_OBJECTS=1 LD_WARN=yes LD_BIND_NOW=yes
LD_LIBRARY_VERSION=$verify_out LD_VERBOSE= LD_DEBUG="unused" "$@

Backtrace is looks like that:
(gdb) bt
#0  0x00007efccf094c87 in __cpu_indicator_init () from /lib64/libgcc_s.so.1
#1  0x0000000000401178 in ?? ()
#2  0x00007fff5f97e220 in ?? ()
#3  0x00007efccf8bce5f in _dl_relocate_object () from
/lib64/ld-linux-x86-64.so.2 
(gdb) disass
Dump of assembler code for function __cpu_indicator_init:
   0x00007efccf094c70 <+0>:     push   %r15
   0x00007efccf094c72 <+2>:     push   %r14
   0x00007efccf094c74 <+4>:     push   %r13
   0x00007efccf094c76 <+6>:     push   %r12
   0x00007efccf094c78 <+8>:     push   %rbp
   0x00007efccf094c79 <+9>:     xor    %ebp,%ebp
   0x00007efccf094c7b <+11>:    push   %rbx
   0x00007efccf094c7c <+12>:    sub    $0x18,%rsp
   0x00007efccf094c80 <+16>:    mov    0x212351(%rip),%rax        #
0x7efccf2a6fd8
=> 0x00007efccf094c87 <+23>:    mov    (%rax),%eax
   0x00007efccf094c89 <+25>:    test   %eax,%eax

             reply	other threads:[~2020-05-06 13:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06 13:37 d at ilvokhin dot com [this message]
2020-05-06 14:42 ` [Bug target/94972] " marxin at gcc dot gnu.org
2024-02-21  0:52 ` 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-94972-4@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).