public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "mjw at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug python/12425] New: Confusing python backtrace on iterator end
Date: Fri, 21 Jan 2011 11:11:00 -0000	[thread overview]
Message-ID: <bug-12425-4717@http.sourceware.org/bugzilla/> (raw)

http://sourceware.org/bugzilla/show_bug.cgi?id=12425

           Summary: Confusing python backtrace on iterator end
           Product: gdb
           Version: archer
            Status: NEW
          Severity: normal
          Priority: P2
         Component: python
        AssignedTo: unassigned@sourceware.org
        ReportedBy: mjw@redhat.com


Take the following silly example:

#include <map>
#include <string>

struct foo
{
  int a;
  int b;
};

int main(int argc, char **argv)
{
  std::map<std::string, foo> map;

  foo f = { 1, 2 };
  map.insert (std::pair<std::string, foo> ("first", f));

  std::map<std::string, foo>::iterator it = map.begin ();
  it++;

  return 0;
}

GNU gdb (GDB) Fedora (7.2-26.fc14)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/foo...done.
(gdb) break main
Breakpoint 1 at 0x400b5d: file foo.cpp, line 12.
(gdb) n
The program is not being run.
(gdb) r
Starting program: /tmp/foo 

Breakpoint 1, main (argc=1, argv=0x7fffffffe278) at foo.cpp:12
12      std::map<std::string, foo> map;
(gdb) n
14      foo f = { 1, 2 };
(gdb) n
15      map.insert (std::pair<std::string, foo> ("first", f));
(gdb) n
17      std::map<std::string, foo>::iterator it = map.begin ();
(gdb) n
18      it++;
(gdb) p it
$1 = {first = "first", second = {a = 1, b = 2}}
(gdb) n
20      return 0;
(gdb) p it
$2 = {first = Traceback (most recent call last):
  File "/usr/lib64/../share/gcc-4.5.1/python/libstdcxx/v6/printers.py", line
549, in to_string
    return self.val['_M_dataplus']['_M_p'].lazy_string (length = len)
RuntimeError: Cannot access memory at address 0xffffffffffffffe9
, second = {a = -7944, b = 32767}}

It isn't so much surprising that the printing fails, since we are now at it ==
map.end(). But you might see this sometimes when you forgot, or when taking an
iterator when a map is empty so map.begin () == map.end ().

It would be nice to not get that RuntimeError and partial python backtrace.
It doesn't really add any information, except that the string couldn't be
shown.

Ideally it would detect the iterator ran out and just report that. If that
isn't possible then please don't print these internal python printer errors
that are just confusing and don't add any useful information.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


             reply	other threads:[~2011-01-21 11:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-21 11:11 mjw at redhat dot com [this message]
2011-01-25 21:52 ` [Bug python/12425] " tromey at redhat dot com
2011-01-28 17:18 ` tromey at redhat dot com
2011-01-28 18:35 ` mjw at redhat dot com

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-12425-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).