Debian Bug report logs - #776893
gdb: pretty-printing C++ std::lists is broken sometimes

version graph

Package: gdb; Maintainer for gdb is Héctor Orón Martínez <[email protected]>; Source for gdb is src:gdb (PTS, buildd, popcon).

Reported by: Roland Hieber <[email protected]>

Date: Mon, 2 Feb 2015 23:36:02 UTC

Severity: normal

Found in versions gdb/7.4.1+dfsg-0.1, gdb/7.7.1+dfsg-5, gdb/7.8.2-1

Reply or subscribe to this bug.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to [email protected], Héctor Orón Martínez <[email protected]>:
Bug#776893; Package gdb. (Mon, 02 Feb 2015 23:36:06 GMT) (full text, mbox, link).


Acknowledgement sent to Roland Hieber <[email protected]>:
New Bug report received and forwarded. Copy sent to Héctor Orón Martínez <[email protected]>. (Mon, 02 Feb 2015 23:36:06 GMT) (full text, mbox, link).


Message #5 received at [email protected] (full text, mbox, reply):

From: Roland Hieber <[email protected]>
To: Debian Bug Tracking System <[email protected]>
Subject: gdb: pretty-printing C++ std::lists is broken sometimes
Date: Tue, 03 Feb 2015 00:24:06 +0100
[Message part 1 (text/plain, inline)]
Package: gdb
Version: 7.7.1+dfsg-5
Severity: normal

Dear Maintainer,

it seems pretty-printing std::lists is broken sometimes. Consider the following
C++11 program:

-------- 8< --------
#include <iostream>
#include <string>
#include <list>

class Msg {
public:
	std::list<std::string> params_;
	std::list<std::string> params() const { return params_; }
	Msg(const std::list<std::string>& params) : params_(params) {
	}
};

int main() {
	std::list<std::string> p = { "foo", "bar", "baz" };
	Msg msg(p);                                    // (A)
	std::cout << msg.params().size() << std::endl; // prints 3
	auto asdf = msg.params();                      // (B)
	for (auto a : msg.params()) {
		std::cout << a << std::endl;                 // prints foo, bar, baz
	}
	return 0;
}
-------- >8 --------

When I step through the program, after line (A), printing msg.params_ yields
the correct list contents, but printing msg.params() yields garbled characters
and a list with > 31 entries (see attached gdb log). Further investigation shows
that when I try to print msg.params().size(), I get "Attempt to take address of
value not located in memory.", and printing the variable asdf in line (B) also
yields the correct results.

All of this also happens with std::list<int> and std::list<double>, but not with
std::maps, std::vectors or std::sets. In any case, all values are printed
correctly to the console, so the underlying memory is apparently fine.

Thanks for listening,
 - Roland


-- System Information:
Debian Release: 8.0
  APT prefers testing
  APT policy: (200, 'testing'), (170, 'unstable'), (150, 'testing-proposed-updates'), (150, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.14-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages gdb depends on:
ii  libbabeltrace-ctf1  1.2.3-2
ii  libbabeltrace1      1.2.3-2
ii  libc6               2.19-13
ii  libexpat1           2.1.0-6+b3
ii  liblzma5            5.1.1alpha+20120614-2+b3
ii  libncurses5         5.9+20140913-1+b1
ii  libpython3.4        3.4.2-1
ii  libreadline6        6.3-8+b2
ii  libtinfo5           5.9+20140913-1+b1
ii  zlib1g              1:1.2.8.dfsg-2+b1

Versions of packages gdb recommends:
ii  gdbserver             7.7.1+dfsg-5
ii  libc6-dbg [libc-dbg]  2.19-13

Versions of packages gdb suggests:
pn  gdb-doc  <none>

-- no debconf information
[gdb-output (text/plain, attachment)]

Marked as found in versions gdb/7.8.2-1. Request was from Roland Hieber <[email protected]> to [email protected]. (Mon, 02 Feb 2015 23:54:04 GMT) (full text, mbox, link).


Marked as found in versions gdb/7.4.1+dfsg-0.1. Request was from Samuel Bronson <[email protected]> to [email protected]. (Tue, 03 Feb 2015 06:51:04 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Sun Sep 22 07:32:47 2024; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.