This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug c++/17734] New: Printing a std::string member hangs after clang compile
- From: "joel at walker9 dot net" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Fri, 19 Dec 2014 21:29:56 +0000
- Subject: [Bug c++/17734] New: Printing a std::string member hangs after clang compile
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=17734
Bug ID: 17734
Summary: Printing a std::string member hangs after clang
compile
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: c++
Assignee: unassigned at sourceware dot org
Reporter: joel at walker9 dot net
When the following code is compiled with clang++, breaking on MyClass::test
then printing str hangs GDB. It doesn't respond to sigterms/sigints and
consumes 100% cpu. Interestingly, the problem doesn't occur when I compile with
g++. In addition, the problem does not occur when printing a local std::string.
#include <iostream>
#include <string>
struct MyClass
{
MyClass()
: str("Hello World")
{}
void test()
{
std::cout << str << std::endl;
}
std::string str;
};
int main()
{
MyClass inst;
inst.test();
return 0;
}
Here are some versions. Note that I tested with 2 GDB versions, including the
latest HEAD.
joel ~> uname -a
Linux walker11 3.16.0-28-generic #38-Ubuntu SMP Fri Dec 12 17:37:40 UTC 2014
x86_64 x86_64 x86_64 GNU/Linux
joel ~> clang++ --version
Ubuntu clang version 3.5.0-4ubuntu2 (tags/RELEASE_350/final) (based on LLVM
3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
joel ~> gdb --version
GNU gdb (Ubuntu 7.8-1ubuntu4) 7.8.0.20141001-cvs
...
joel ~> /tmp/binutils-gdb/gdb/gdb --version
GNU gdb (GDB) 7.8.50.20141219-cvs
...
Compilation command:
clang++ -g -Wall test_string.cpp
GDB session:
joel /tmp> ./binutils-gdb/gdb/gdb ./a.out
Python Exception <type 'exceptions.ImportError'> No module named gdb:
./binutils-gdb/gdb/gdb: warning:
Could not load the Python gdb module from `/usr/local/share/gdb/python'.
Limited Python support is available from the _gdb module.
Suggest passing --data-directory=/path/to/gdb/data-directory.
GNU gdb (GDB) 7.8.50.20141219-cvs
Copyright (C) 2014 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-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
/home/joel/.gdbinit:1: Error in sourced command file:
Undefined command: "". Try "help".
Reading symbols from ./a.out...done.
(gdb) break MyClass::test()
Breakpoint 1 at 0x400cea: file test_string.cpp, line 12.
(gdb) r
Starting program: /tmp/a.out
Breakpoint 1, MyClass::test (this=0x7fffffffe3b0) at test_string.cpp:12
12 std::cout << str << std::endl;
(gdb) print str
fish: Job 1, â./binutils-gdb/gdb/gdb ./a.out â terminated by signal SIGKILL
(Forced quit)
--
You are receiving this mail because:
You are on the CC list for the bug.