public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "david.spickett at linaro dot org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/26196] New: gdb error message is unclear when attempting to load a file >2GB via gdbserver
Date: Thu, 02 Jul 2020 13:37:59 +0000	[thread overview]
Message-ID: <bug-26196-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=26196

            Bug ID: 26196
           Summary: gdb error message is unclear when attempting to load a
                    file >2GB via gdbserver
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: david.spickett at linaro dot org
  Target Milestone: ---

This is related to https://sourceware.org/bugzilla/show_bug.cgi?id=23198, filed
as a new ticket for the gdb error message specifically.

I attempted to debug lldb by attaching gdbserver to it then connecting to that
with gdb. lldb references a shared library that contains its commands. This
library is >2GB in size when built in debug mode.

The error message gdb gives me when trying to load this is:
Reading
/work/open_source/lldb-cross-compile/build-host-debug/bin/../lib/liblldb.so.11git
from remote target...
Error while mapping shared library sections:
`target:/work/open_source/lldb-cross-compile/build-host-debug/bin/../lib/liblldb.so.11git':
not in executable format: file format not recognized

(gdb) info shared
>From                To                  Syms Read   Shared Object Library
<...>
                                        No         
/work/open_source/lldb-cross-compile/build-host-debug/bin/../lib/liblldb.so.11git

We can see from logging in gdbserver that the failure is because the offset
sent to pread is invalid when trying to get the first section header.
require_int in gdbserver is checking that the offset is not > 0x80000000.
getpkt ("vFile:pread:a,3fff,9ab473c8");  [no ack sent]
putpkt ("$F-1,16#37"); [noack mode] // 0x16 aka FILEIO_EINVAL

(https://sourceware.org/gdb/current/onlinedocs/gdb/Host-I_002fO-Packets.html)

The error message implies that the format is incorrect (although it earlier
read the ELF bytes) and I initially thought that gdbserver had read the symlink
as a real file (liblldb.so.11git links to the real .so). Which I'm not sure is
even possible but I tried to narrow it down from there.

I think this error message should say something like "<file>: file offset of X
is beyond limit of vFile:pread packet". (or bail a lot earlier once we see that
the size is >2GB)
The root issue would be the vFile packet itself but this is a niche use case
and you can workaround it by setting a sysroot to load the file from the local
machine. An improved error would make it clearer what you need to do.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2020-07-02 13:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02 13:37 david.spickett at linaro dot org [this message]
2020-07-07 16:08 ` [Bug gdb/26196] " gbenson at redhat dot com
2022-04-05 18:30 ` [Bug remote/26196] " tromey at sourceware dot 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-26196-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.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).