Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Doug Evans <xdje42@gmail.com>
Cc: Doug Evans <dje@google.com>, gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH v12 00/32] Validate binary before use
Date: Wed, 02 Sep 2015 19:12:00 -0000	[thread overview]
Message-ID: <20150902191249.GA17111@host1.jankratochvil.net> (raw)
In-Reply-To: <CAP9bCMToN5taa2fOP4V17=4hL4cfusGhF9FnTnb3imqgys+LFA@mail.gmail.com>

Hello Doug,

this discussion is offtopic for this patchset and it touches areas I am not
yet sure how I will change/rewrite before posting the linux-nat/corefile next
part.  OTOH that's also good as it can be at least designed ahead of coding.


On Wed, 02 Sep 2015 17:22:35 +0200, Doug Evans wrote:
> On Wed, Sep 2, 2015 at 8:14 AM, Jan Kratochvil
> <jan.kratochvil@redhat.com> wrote:
> > The Fedora patchset intentionally disables build-ids verification/lookup if
> > random-program is specified as it was breaking some compatibility
> 
> Interesting. What kind of compatibility?

I was looking up what it really was and there are two reasons:

(1) I did not want to change behavior of Fedora fork of GDB against upstream.
    This is why I tried to keep the behavior of case
      "gdb random-program random-core"
    the same as upstream GDB has.

    This can be sure changed now when/if the feature gets upstreamed.

(2) As discussed below for "Fedora native" loading of core-files fully
    according to build-ids any behavior is OK as such case does not work for
    upstream GDB at all.  In such case the strict build-id matching is the
    best one for user IMO as shown in:
      non-matching build-id libraries should not be loaded for `gdb -c'
      https://bugzilla.redhat.com/show_bug.cgi?id=524572
    +
      Base the backtrace strictly on build-id
      https://bugzilla.redhat.com/show_bug.cgi?id=525721


> > and IMO it
> > does not make sense to specify random-program if build-ids are available.
> 
> Why is that?
> [Just because one has a build id doesn't necessarily mean one knows where
> a program is. Or did I misunderstand?]

On Fedora for build-id -> filename mapping one needs the appropriate
n-debuginfo-v-r.a.rpm installed.  IMO on development machines they are
installed most of the time because otherwise Fedora GDB all the time annoys
users by complaints they should get installed.  If it is missing for any reason
one can easily get it installed as shown at the end of this mail.  (OK, maybe
it can be made even easier but that would require better integration with the
ever-changing packaging front-ends on Fedora.)

There were some discussions how the build-id -> filename mapping should be
stored.  Currently it is done by on-disk symlinks in /usr/lib/debug/.build-id/
stored in *-debuginfo.rpm (therefore to get just the build-id -> filename
mapping symlink even for an already installed binary one needs to install
*-debuginfo.rpm).
# ls -l /usr/lib/debug/.build-id/b3/e636b621bb16456d201edca942442bdbf045f9*
lrwxrwxrwx 1 root root 21 Jul 16 10:42 /usr/lib/debug/.build-id/b3/e636b621bb16456d201edca942442bdbf045f9 -> ../../../../bin/sleep*
lrwxrwxrwx 1 root root 25 Jul 16 10:42 /usr/lib/debug/.build-id/b3/e636b621bb16456d201edca942442bdbf045f9.debug -> ../../usr/bin/sleep.debug
# rpm -qf /usr/lib/debug/.build-id/b3/e636b621bb16456d201edca942442bdbf045f9{,.debug} /bin/sleep /usr/lib/debug/usr/bin/sleep.debug
coreutils-debuginfo-8.24-2.fc23.x86_64
coreutils-debuginfo-8.24-2.fc23.x86_64
coreutils-8.24-2.fc23.x86_64
coreutils-debuginfo-8.24-2.fc23.x86_64

Other possibilities would be to store build-ids into .rpm tags even in the main
binary .rpms; but that would make dependency of the build-ids resolving on rpm.
Another possibility is to include the build-id symlinks into the main binary
packages; but those symlinks can take a lot of disk space even when no
debugging is required. Or to have some global or per-package sqlite database
etc.


Jan


$ gdb -q core.23526 
[New LWP 23526]
Missing separate debuginfo for the main executable file
Try: dnf --enablerepo='*debug*' install /usr/lib/debug/.build-id/b3/e636b621bb16456d201edca942442bdbf045f9
Core was generated by `sleep 1h'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f2810648bf0 in ?? ()
"/home/jkratoch/t/core.23526" is a core file.
Please specify an executable to debug.
(gdb) q
# dnf --enablerepo='*debug*' install /usr/lib/debug/.build-id/b3/e636b621bb16456d201edca942442bdbf045f9
[...]
Installed:
  coreutils-debuginfo.x86_64 8.24-2.fc23                                                                                                 
$ gdb -q core.23526 
[New LWP 23526]
Reading symbols from /usr/bin/sleep...Reading symbols from /usr/lib/debug/usr/bin/sleep.debug...done.
done.

warning: Ignoring non-absolute filename: <linux-vdso.so.1>
Missing separate debuginfo for linux-vdso.so.1
Try: dnf --enablerepo='*debug*' install /usr/lib/debug/.build-id/2b/fef7432912bcc87752ef9e66b1ddb71d7485f5
Core was generated by `sleep 1h'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f2810648bf0 in __nanosleep_nocancel () from /lib64/libc.so.6
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.21.90-21.fc23.x86_64
(gdb) q
# dnf --enablerepo='*debug*' install /usr/lib/debug/.build-id/2b/fef7432912bcc87752ef9e66b1ddb71d7485f5
Last metadata expiration check performed 0:03:45 ago on Wed Sep  2 20:53:07 2015.
No package /usr/lib/debug/.build-id/2b/fef7432912bcc87752ef9e66b1ddb71d7485f5 available.
Error: no package matched
 --- Because matching kernel.rpm running on host OS is not available in this guest OS.
# dnf debuginfo-install glibc-2.21.90-21.fc23.x86_64
[...]
Installed:
  glibc-debuginfo.x86_64 2.22-2.fc23     glibc-debuginfo-common.x86_64 2.22-2.fc23     nss-softokn-debuginfo.x86_64 3.20.0-1.0.fc23    
$ gdb -q core.26016 
[New LWP 26016]
Reading symbols from /usr/bin/sleep...Reading symbols from /usr/lib/debug/usr/bin/sleep.debug...done.
done.

warning: Ignoring non-absolute filename: <linux-vdso.so.1>
Missing separate debuginfo for linux-vdso.so.1
Try: dnf --enablerepo='*debug*' install /usr/lib/debug/.build-id/2b/fef7432912bcc87752ef9e66b1ddb71d7485f5
Core was generated by `sleep 1h'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f3fd8bd6870 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:84
84	T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
(gdb) bt
#0  0x00007f3fd8bd6870 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:84
#1  0x000055f9f5bf829f in rpl_nanosleep (requested_delay=requested_delay@entry=0x7ffe1323cb80, 
    remaining_delay=remaining_delay@entry=0x0) at lib/nanosleep.c:85
#2  0x000055f9f5bf8100 in xnanosleep (seconds=<optimized out>) at lib/xnanosleep.c:51
#3  0x000055f9f5bf5a1d in main (argc=<optimized out>, argv=<optimized out>) at src/sleep.c:145
(gdb) q


  reply	other threads:[~2015-09-02 19:12 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-21 21:20 Jan Kratochvil
2015-08-21 21:20 ` [PATCH v12 04/32] Move linux_find_memory_regions_full & co Jan Kratochvil
2015-08-21 21:20 ` [PATCH v12 05/32] gdbserver build-id attribute generator Jan Kratochvil
2015-08-22  7:17   ` Eli Zaretskii
2015-08-21 21:20 ` [PATCH v12 03/32] Prepare linux_find_memory_regions_full & co. for move Jan Kratochvil
2015-08-21 21:20 ` [PATCH v12 01/32] Create empty common/linux-maps.[ch] and common/target-utils.[ch] Jan Kratochvil
2015-08-21 21:20 ` [PATCH v12 02/32] Move gdb_regex* to common/ Jan Kratochvil
2015-08-21 21:21 ` [PATCH v12 10/32] Code cleanup: Add enum for openp_flags Jan Kratochvil
2015-08-21 21:21 ` [PATCH v12 06/32] Validate symbol file using build-id Jan Kratochvil
2015-08-22  7:23   ` Eli Zaretskii
2015-08-22 19:19     ` Jan Kratochvil
2015-08-21 21:21 ` [PATCH v12 12/32] Code cleanup: Remove openp parameter mode Jan Kratochvil
2015-08-21 21:21 ` [PATCH v12 08/32] Permit multiple sysroot directories Jan Kratochvil
2015-08-22  7:31   ` Eli Zaretskii
2015-08-22 19:24     ` Jan Kratochvil
2015-08-21 21:21 ` [PATCH v12 07/32] Code cleanup: Make solib_find_1 variable const Jan Kratochvil
2015-08-21 21:21 ` [PATCH v12 11/32] Code cleanup: Remove OPF_RETURN_REALPATH Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 15/32] gdb_bfd_open_from_target: Support real fd Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 18/32] Refactor openp() to return file_location Jan Kratochvil
2015-08-25 19:07   ` [PATCH v13 " Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 19/32] solib_find: Make it use file_location Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 13/32] Code cleanup: openp parameter filename_opened is never NULL Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 14/32] Provide new gdb_bfd_open_from_target Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 20/32] symfile_bfd_open: Make it use openp_bfd() Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 16/32] gdb_bfd_open_from_target: Optionally do not close fd Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 17/32] Add file_location utility functions Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 09/32] Change sysroot to ":target:" Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 27/32] build_id_verify: Make it more verbose Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 26/32] solib_bfd_open: Optimize opening twice Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 21/32] build_id_to_debug_bfd: Make it also non-.debug capable Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 23/32] build_id_to_bfd: Make it return file_location Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 24/32] solib_find: Search also by build-id Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 22/32] Add dummy build-id params to prototypes Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 25/32] Verify the build-id Jan Kratochvil
2015-08-21 21:24 ` [PATCH v12 28/32] Tests for validate symbol file using build-id Jan Kratochvil
2015-08-21 21:24 ` [PATCH v12 29/32] testcase: Test also locating shlibs by build-id Jan Kratochvil
2015-08-21 21:24 ` [PATCH v12 32/32] Support build-id for main executables Jan Kratochvil
2015-08-21 21:24 ` [PATCH v12 30/32] Code cleanup: New hex2bin_allocate() Jan Kratochvil
2015-08-21 21:24 ` [PATCH v12 31/32] Make only user-specified executable and symbol filenames sticky Jan Kratochvil
2015-09-02  3:57 ` [PATCH v12 00/32] Validate binary before use Doug Evans
2015-09-02  7:41   ` Jan Kratochvil
2015-09-02 14:58     ` Doug Evans
2015-09-02 15:14       ` Jan Kratochvil
2015-09-02 15:22         ` Doug Evans
2015-09-02 19:12           ` Jan Kratochvil [this message]
2015-09-15  1:37             ` Doug Evans

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=20150902191249.GA17111@host1.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=xdje42@gmail.com \
    /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