public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/10707] New: c++ pretty-printer barfing on a vector
@ 2009-09-29 21:03 carlton at bactrian dot org
  2009-09-30 16:10 ` [Bug python/10707] " pmuldoon at redhat dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: carlton at bactrian dot org @ 2009-09-29 21:03 UTC (permalink / raw)
  To: gdb-prs

When I try to compile the following C++ code:

#include <string>
#include <vector>

int main() {
  std::string s1("foo");
  std::string s2("bar");
  std::string s3("baz");

  std::vector<std::string> strings;
  strings.push_back(s1);
  strings.push_back(s2);
  strings.push_back(s3);
}

with GCC 4.1.2 (Linux, x86_64)

then, if I set a breakpoint on the next-to-last-line and print out strings, things look normal:

12	  strings.push_back(s3);
(gdb) p strings
$9 = std::vector of length 2, capacity 2 = {"foo", "bar"}

But if I go to the closing brace, I get this:

(gdb) p strings
$10 = std::vector of length 3, capacity 4 = {Traceback (most recent call last):
  File "/home/dcarlton/gdb-c++-python/libstdcxx/v6/printers.py", line 469, in to_string
    return self.val['_M_dataplus']['_M_p'].string (encoding, length = len)
RuntimeError: Cannot access memory at address 0xffffffffffffffe8
, Traceback (most recent call last):
  File "/home/dcarlton/gdb-c++-python/libstdcxx/v6/printers.py", line 469, in to_string
    return self.val['_M_dataplus']['_M_p'].string (encoding, length = len)
RuntimeError: Error reading string from inferior: Input/output error
, Traceback (most recent call last):
  File "/home/dcarlton/gdb-c++-python/libstdcxx/v6/printers.py", line 469, in to_string
    return self.val['_M_dataplus']['_M_p'].string (encoding, length = len)
RuntimeError: Error reading string from inferior: Input/output error
}

(I assume destructors shouldn't have been run at that line yet, right?  Or have they?)

I'm using the pretty-printers from GCC svn head as of today.  (Rev 152291.)

-- 
           Summary: c++ pretty-printer barfing on a vector
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: carlton at bactrian dot org
                CC: gdb-prs at sourceware dot org


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug python/10707] c++ pretty-printer barfing on a vector
  2009-09-29 21:03 [Bug python/10707] New: c++ pretty-printer barfing on a vector carlton at bactrian dot org
@ 2009-09-30 16:10 ` pmuldoon at redhat dot com
  2009-09-30 17:32 ` carlton at bactrian dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pmuldoon at redhat dot com @ 2009-09-30 16:10 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From pmuldoon at redhat dot com  2009-09-30 16:10 -------
I copied your program and added a return for clarity:

#include <string>
#include <vector>

int main() {
  std::string s1("foo");
  std::string s2("bar");
  std::string s3("baz");

  std::vector<std::string> strings;
  strings.push_back(s1);
  strings.push_back(s2);
  strings.push_back(s3);

  return 0;
}

so when on the "return 0" statement:

12	  strings.push_back(s3);
(gdb) 
14	  return 0;
(gdb) p strings
$1 = std::vector of length 3, capacity 4 = {"foo", "bar", "baz"}

But once past that:

(gdb) n

15	}
(gdb) p strings
$2 = 0


I think the strings were  garbage collected in your original case but not the
encapsulating vector. What's your opinion?

On the printed garbage, what you are seeing also is the string printer trying to
print just random memory. There's another bug relating to this:

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



-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug python/10707] c++ pretty-printer barfing on a vector
  2009-09-29 21:03 [Bug python/10707] New: c++ pretty-printer barfing on a vector carlton at bactrian dot org
  2009-09-30 16:10 ` [Bug python/10707] " pmuldoon at redhat dot com
@ 2009-09-30 17:32 ` carlton at bactrian dot org
  2009-10-01  7:34 ` pmuldoon at redhat dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: carlton at bactrian dot org @ 2009-09-30 17:32 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From carlton at bactrian dot org  2009-09-30 17:32 -------
Hmm, yeah, I should have tried that.  Sounds like a plausible explanation; pity there's no way without a 
return statement (or, I guess, without stepping into functions) to get to the vector after the last statement 
but before destructors start firing, but maybe we're at the compiler's mercy for that?

-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug python/10707] c++ pretty-printer barfing on a vector
  2009-09-29 21:03 [Bug python/10707] New: c++ pretty-printer barfing on a vector carlton at bactrian dot org
  2009-09-30 16:10 ` [Bug python/10707] " pmuldoon at redhat dot com
  2009-09-30 17:32 ` carlton at bactrian dot org
@ 2009-10-01  7:34 ` pmuldoon at redhat dot com
  2009-10-27 13:38 ` pmuldoon at redhat dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pmuldoon at redhat dot com @ 2009-10-01  7:34 UTC (permalink / raw)
  To: gdb-prs



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


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug python/10707] c++ pretty-printer barfing on a vector
  2009-09-29 21:03 [Bug python/10707] New: c++ pretty-printer barfing on a vector carlton at bactrian dot org
                   ` (2 preceding siblings ...)
  2009-10-01  7:34 ` pmuldoon at redhat dot com
@ 2009-10-27 13:38 ` pmuldoon at redhat dot com
  2009-10-27 17:20 ` carlton at bactrian dot org
  2009-11-02 17:27 ` pmuldoon at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: pmuldoon at redhat dot com @ 2009-10-27 13:38 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From pmuldoon at redhat dot com  2009-10-27 13:38 -------
I had a look again at this today, just to make sure and it is just trying to
interpret garbage data/access data that is no longer there. I'm not sure what,
from a pretty-printing perspective we can do about this. Possibly if there was
some way to flag if a local was initialized/in-scope. Anyway, do you want to
close this and change the resolution?

-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug python/10707] c++ pretty-printer barfing on a vector
  2009-09-29 21:03 [Bug python/10707] New: c++ pretty-printer barfing on a vector carlton at bactrian dot org
                   ` (3 preceding siblings ...)
  2009-10-27 13:38 ` pmuldoon at redhat dot com
@ 2009-10-27 17:20 ` carlton at bactrian dot org
  2009-11-02 17:27 ` pmuldoon at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: carlton at bactrian dot org @ 2009-10-27 17:20 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From carlton at bactrian dot org  2009-10-27 17:20 -------
I'm happy for y'all to do whatever you see fit for this bug.

-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug python/10707] c++ pretty-printer barfing on a vector
  2009-09-29 21:03 [Bug python/10707] New: c++ pretty-printer barfing on a vector carlton at bactrian dot org
                   ` (4 preceding siblings ...)
  2009-10-27 17:20 ` carlton at bactrian dot org
@ 2009-11-02 17:27 ` pmuldoon at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: pmuldoon at redhat dot com @ 2009-11-02 17:27 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From pmuldoon at redhat dot com  2009-11-02 17:27 -------
In this particular bug, it was a case of the vector not being
initialized/allocated when the print command was issued (due to the program
being at an end).

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

end of thread, other threads:[~2009-11-02 17:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-29 21:03 [Bug python/10707] New: c++ pretty-printer barfing on a vector carlton at bactrian dot org
2009-09-30 16:10 ` [Bug python/10707] " pmuldoon at redhat dot com
2009-09-30 17:32 ` carlton at bactrian dot org
2009-10-01  7:34 ` pmuldoon at redhat dot com
2009-10-27 13:38 ` pmuldoon at redhat dot com
2009-10-27 17:20 ` carlton at bactrian dot org
2009-11-02 17:27 ` pmuldoon 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).