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