public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/29999] New: Bogus error message printed when debuginfod doesn't find source file
@ 2023-01-13 14:49 simark at simark dot ca
  2023-01-13 14:49 ` [Bug gdb/29999] " simark at simark dot ca
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: simark at simark dot ca @ 2023-01-13 14:49 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 29999
           Summary: Bogus error message printed when debuginfod doesn't
                    find source file
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: simark at simark dot ca
  Target Milestone: ---

Debugging on Arch Linux with DEBUGINFOD_URLS=https://debuginfod.archlinux.org,
stopping into a glibc function for which debuginfod didn't find the source file
(for whatever reason), GDB printed:

__libc_start_call_main (main=main@entry=0x555555555139 <main>,
argc=argc@entry=1, argv=argv@entry=0x7fffffffd6f8) at
../sysdeps/nptl/libc_start_call_main.h:74
Downloading source file
/usr/src/debug/glibc/csu/../sysdeps/nptl/libc_start_call_main.h
74      ../sysdeps/nptl/libc_start_call_main.h: Directory not empty.   

The next times (when the cache was populated, I suppose), I got:

__libc_start_call_main (main=main@entry=0x555555555139 <main>,
argc=argc@entry=1, 
    argv=argv@entry=0x7fffffffd6f8) at
../sysdeps/nptl/libc_start_call_main.h:74
74      ../sysdeps/nptl/libc_start_call_main.h: Bad file descriptor.

I think this use of errno, in print_source_lines_base, is incorrect:

https://gitlab.com/gnutools/binutils-gdb/-/blob/6f9f448118eaeaf006f867a25699aef7d8c72770/gdb/source.c#L1357

The last thing we did before this was to call into debuginfod_find_source,
which returned -2 (meaning ENOENT, which makes sense).  But the errno value
after calling debuginfod_find_source is not defined, and I think this results
in an error message that does not make sense.

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

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

* [Bug gdb/29999] Bogus error message printed when debuginfod doesn't find source file
  2023-01-13 14:49 [Bug gdb/29999] New: Bogus error message printed when debuginfod doesn't find source file simark at simark dot ca
@ 2023-01-13 14:49 ` simark at simark dot ca
  2023-01-14  1:07 ` amerey at redhat dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: simark at simark dot ca @ 2023-01-13 14:49 UTC (permalink / raw)
  To: gdb-prs

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

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amerey at redhat dot com

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

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

* [Bug gdb/29999] Bogus error message printed when debuginfod doesn't find source file
  2023-01-13 14:49 [Bug gdb/29999] New: Bogus error message printed when debuginfod doesn't find source file simark at simark dot ca
  2023-01-13 14:49 ` [Bug gdb/29999] " simark at simark dot ca
@ 2023-01-14  1:07 ` amerey at redhat dot com
  2023-01-14  1:14 ` simark at simark dot ca
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: amerey at redhat dot com @ 2023-01-14  1:07 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Aaron Merey <amerey at redhat dot com> ---
Created attachment 14592
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14592&action=edit
patch

(In reply to Simon Marchi from comment #0)
> I think this use of errno, in print_source_lines_base, is incorrect:
> 
> https://gitlab.com/gnutools/binutils-gdb/-/blob/
> 6f9f448118eaeaf006f867a25699aef7d8c72770/gdb/source.c#L1357
> 
> The last thing we did before this was to call into debuginfod_find_source,
> which returned -2 (meaning ENOENT, which makes sense).  But the errno value
> after calling debuginfod_find_source is not defined, and I think this
> results in an error message that does not make sense.

It looks like errno gets set in find_and_open_source (in the case of ENOENT at
least) before the call to debuginfod_find_source:

https://gitlab.com/gnutools/binutils-gdb/-/blob/6f9f448118eaeaf006f867a25699aef7d8c72770/gdb/source.c#L1179

However function calls within debuginfod_find_source may end up reassigning
errno to a value unrelated to the status of the download, even if the download
is successful. debuginfod_find_source returns a negative errno indicating the
actual reason for a failed download. This is the errno that should be reported
to the user, not one related to routine cache creation, for example.

We also don't want to hide an errno set in find_and_open_source. debuginfod
errors are already reported in the debuginfod progress output, so I think we
should save errno before calling debuginfod_find_source and revert errno to the
saved value afterwards. This way both debuginfod errors and
find_and_open_source errors are correctly reported to the user.

I've attached a patch for this.

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

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

* [Bug gdb/29999] Bogus error message printed when debuginfod doesn't find source file
  2023-01-13 14:49 [Bug gdb/29999] New: Bogus error message printed when debuginfod doesn't find source file simark at simark dot ca
  2023-01-13 14:49 ` [Bug gdb/29999] " simark at simark dot ca
  2023-01-14  1:07 ` amerey at redhat dot com
@ 2023-01-14  1:14 ` simark at simark dot ca
  2023-02-11  2:12 ` cvs-commit at gcc dot gnu.org
  2023-02-11  2:16 ` amerey at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: simark at simark dot ca @ 2023-01-14  1:14 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Simon Marchi <simark at simark dot ca> ---
If possible, it would be nice to make internal GDB functions (like
find_and_open_source) return error codes explicitly, instead of relying of
errno.  I think that will make the code clearer than saving and restoring
errno.

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

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

* [Bug gdb/29999] Bogus error message printed when debuginfod doesn't find source file
  2023-01-13 14:49 [Bug gdb/29999] New: Bogus error message printed when debuginfod doesn't find source file simark at simark dot ca
                   ` (2 preceding siblings ...)
  2023-01-14  1:14 ` simark at simark dot ca
@ 2023-02-11  2:12 ` cvs-commit at gcc dot gnu.org
  2023-02-11  2:16 ` amerey at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-11  2:12 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Aaron Merey <amerey@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8cc96ee4169f631917d048cbaeec14ddf8ccb90d

commit 8cc96ee4169f631917d048cbaeec14ddf8ccb90d
Author: Aaron Merey <amerey@redhat.com>
Date:   Thu Feb 9 20:35:32 2023 -0500

    gdb/source: Fix open_source_file error handling

    open_source_file relies on errno to communicate the reason for a missing
    source file.

    open_source_file may also call debuginfod_find_source.  It is possible
    for debuginfod_find_source to set errno to a value unrelated to the
    reason for a failed download.

    This can result in bogus error messages being reported as the reason for
    a missing source file.  The following error message should instead be
    "No such file or directory":

      Temporary breakpoint 1, 0x00005555556f4de0 in main ()
      (gdb) list
      Downloading source file
/usr/src/debug/glibc-2.36-8.fc37.x86_64/elf/<built-in>
      1       /usr/src/debug/glibc-2.36-8.fc37.x86_64/elf/<built-in>: Directory
not empty.

    Fix this by having open_source_file return a negative errno if it fails
    to open a source file.  Use this value to generate the error message
    instead of errno.

    Approved-By: Tom Tromey <tom@tromey.com>
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29999

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

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

* [Bug gdb/29999] Bogus error message printed when debuginfod doesn't find source file
  2023-01-13 14:49 [Bug gdb/29999] New: Bogus error message printed when debuginfod doesn't find source file simark at simark dot ca
                   ` (3 preceding siblings ...)
  2023-02-11  2:12 ` cvs-commit at gcc dot gnu.org
@ 2023-02-11  2:16 ` amerey at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: amerey at redhat dot com @ 2023-02-11  2:16 UTC (permalink / raw)
  To: gdb-prs

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

Aaron Merey <amerey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #4 from Aaron Merey <amerey at redhat dot com> ---
Fixed in the above commit.

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

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

end of thread, other threads:[~2023-02-11  2:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-13 14:49 [Bug gdb/29999] New: Bogus error message printed when debuginfod doesn't find source file simark at simark dot ca
2023-01-13 14:49 ` [Bug gdb/29999] " simark at simark dot ca
2023-01-14  1:07 ` amerey at redhat dot com
2023-01-14  1:14 ` simark at simark dot ca
2023-02-11  2:12 ` cvs-commit at gcc dot gnu.org
2023-02-11  2:16 ` amerey at redhat 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).