public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Aaron Merey <amerey@redhat.com>
To: Andrew Burgess <aburgess@redhat.com>
Cc: Aaron Merey via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 6/7] gdb/testsuite/gdb.debuginfod: Add lazy downloading tests
Date: Tue, 2 May 2023 12:24:13 -0400	[thread overview]
Message-ID: <CAJDtP-QDy7c=B3XtA+hH32hueqvcbgNP1jaiWRt7dabffQhStw@mail.gmail.com> (raw)
In-Reply-To: <87ilda91kc.fsf@redhat.com>

Hi Andrew,

On Tue, May 2, 2023 at 11:48 AM Andrew Burgess <aburgess@redhat.com> wrote:
> I compile GDB with both '-D_GLIBCXX_DEBUG=1' and
> '-D_GLIBCXX_DEBUG_PEDANTIC=1' defined.
>
> After applying this series I see the following GDB crash when running
> the fetch_src_and_symbols.exp test:
>
>   (gdb) file
>   No executable file now.
>   /usr/include/c++/9/debug/safe_iterator.h:597:
>   In function:
>       __gnu_debug::_Safe_iterator<_Iterator, _Sequence,
>       std::bidirectional_iterator_tag>& __gnu_debug::_Safe_iterator<_Iterator,
>       _Sequence, std::bidirectional_iterator_tag>::operator--() [with
>       _Iterator = std::__cxx1998::_List_iterator<std::unique_ptr<objfile> >;
>       _Sequence = std::__debug::list<std::unique_ptr<objfile> >]
>
>   Error: attempt to decrement a dereferenceable (start-of-sequence) iterator.

Thanks for spotting this. It looks like the culprit is from the following change
in patch 5/7 [1]:

diff --git a/gdbsupport/iterator-range.h b/gdbsupport/iterator-range.h
index e934f5ebf01..853ebb9074a 100644
--- a/gdbsupport/iterator-range.h
+++ b/gdbsupport/iterator-range.h
@@ -61,4 +61,49 @@ struct iterator_range
+template <typename IteratorType>
+struct reverse_iterator_range
+{
+  using iterator = IteratorType;
+
+  /* Create a reverse iterator range using explicit BEGIN and END
iterators.  */
+  template <typename... Args>
+  reverse_iterator_range (IteratorType begin, IteratorType end)
+    : m_begin (std::move (end)), m_end (std::move (begin))
+  {
+    if (m_begin != m_end)
+      {
+ /* M_BEGIN is the base iterator's one-past-the-end.  Increment it
+   so it points to the ranges's last element.  */
+ ++m_begin;
+
+ /* M_END points to the range's first element.  Increment it so it's
+   one-past-the-end.  */
+ ++m_end;
+      }
+  }
[...]

'++m_end' has the effect of decrementing a std::list begin() iterator, though it
should never be dereferenced. I'll fix this and post a follow up to patch 5/7.

Aaron

[1] https://sourceware.org/pipermail/gdb-patches/2023-April/199076.html


  reply	other threads:[~2023-05-02 16:24 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27 19:42 [PATCH 1/7] gdb/debuginfod: Add debuginfod_section_query Aaron Merey
2023-02-27 19:42 ` [PATCH 2/7] gdb: add 'lazy' setting for command 'set debuginfod enabled' Aaron Merey
2023-02-27 19:54   ` Eli Zaretskii
2023-05-24  9:31   ` Andrew Burgess
2023-02-27 19:42 ` [PATCH 3/7] gdb/debuginfod: disable pagination during downloads Aaron Merey
2023-03-03 21:33   ` Tom Tromey
2023-03-06 23:07     ` Aaron Merey
2023-05-24  9:38   ` Andrew Burgess
2023-05-24 18:57     ` Aaron Merey
2023-02-27 19:42 ` [PATCH 4/7] gdb/ui-file: Add newline tracking Aaron Merey
2023-03-07 19:33   ` Tom Tromey
2023-03-07 20:30     ` Aaron Merey
2023-03-07 20:47       ` Tom Tromey
2023-02-27 19:42 ` [PATCH 5/7] gdb/debuginfod: Support on-demand debuginfo downloading Aaron Merey
2023-03-07 20:20   ` Tom Tromey
2023-03-09  0:22     ` Aaron Merey
2023-02-27 19:42 ` [PATCH 6/7] gdb/testsuite/gdb.debuginfod: Add lazy downloading tests Aaron Merey
2023-05-02 15:48   ` Andrew Burgess
2023-05-02 16:24     ` Aaron Merey [this message]
2023-05-24 10:12   ` Andrew Burgess
2023-02-27 19:42 ` [PATCH 7/7] gdb/debuginfod: Add .debug_line downloading Aaron Merey
2023-03-07 20:36   ` Tom Tromey
2023-03-09  0:26     ` Aaron Merey
2023-02-28 11:11 ` [PATCH 1/7] gdb/debuginfod: Add debuginfod_section_query Alexandra Petlanova Hajkova
2023-05-24  9:01 ` Andrew Burgess

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='CAJDtP-QDy7c=B3XtA+hH32hueqvcbgNP1jaiWRt7dabffQhStw@mail.gmail.com' \
    --to=amerey@redhat.com \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@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).