From: asmwarrior <asmwarrior@gmail.com>
To: gdb@sourceware.org
Cc: Xun Xun <xunxun1982@gmail.com>
Subject: gdb crash when I try to print a std::queue (Windows)
Date: Sun, 30 Oct 2011 13:30:00 -0000 [thread overview]
Message-ID: <4EAD4FE7.9050102@gmail.com> (raw)
Hi,I'm bulding a cvs head gdb with python enabled. I'm using Windows XP.
When I try to print a std::queue, gdb crashed. I use a another gdb to test the crash bug.
My test code is below:
----------------------------------------------------------------
#include <wx/wx.h>
#include <string>
#include <map>
#include <list>
#include <stack>
#include <vector>
#include <queue>
#include <windows.h>
const static std::string apms[5]={"&","<",">",""","'"};
int main()
{
wxString *psty = (wxString*) NULL;
wxString wxStr(L"wxString");
wxStr += L" Value";
std::string stdStr("std::string");
stdStr.append(" value");
std::map<int, std::string> m;
m[0] = "000";
m[1] = "111";
wxString& wxStrRef = wxStr;
wxStrRef += L" Ref";
std::string& stdStrRef = stdStr;
stdStrRef += " Ref";
std::list<std::string> l = {"a", "b", "c"};
std::vector<std::string> v = {"a", "b", "c"};
std::queue<std::string> q;
q.push("a");
q.push("b");
std::stack<std::string> s;
s.push("a");
s.push("b");
asm("int $3");
return 0;
}
-------------------------------------------------
You can remove all the other stuffs and leave only the std::queue code.
I build it in mingw gcc 4.4.5, here is the debug log:
gdb-python27.exe is the "debugger", and gdb.exe is the "debugee".
the command "source stl.gdb" is just loading the std c++'s python pretty printer.
E:\code\test_gdb>gdb-python27.exe gdb.exe
GNU gdb (GDB) 7.3.1
Copyright (C) 2011 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 "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from e:\code\test_gdb\gdb.exe...done.
(gdb) r
Starting program: e:\code\test_gdb\gdb.exe
[New Thread 3644.0x1148]
GNU gdb (GDB) 7.3.50.20111030-cvs
Copyright (C) 2011 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 "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) [New Thread 3644.0x194]
[New Thread 3644.0x1370]
file a1.exe
Reading symbols from e:\code\test_gdb\a1.exe...done.
(gdb) source stl.gdb
(gdb) r
Starting program: e:\code\test_gdb\a1.exe
[New Thread 4964.0x1700]
Program received signal SIGTRAP, Trace/breakpoint trap.
main () at e:\code\cb\test_code\gdbpython-demo\main.cpp:41
41 return 0;
(gdb) python print 3
3
(gdb) p q
$1 =
Program received signal SIGSEGV, Segmentation fault.
0x77c47a64 in strncmp () from C:\WINDOWS\system32\msvcrt.dll
(gdb) bt
#0 0x77c47a64 in strncmp () from C:\WINDOWS\system32\msvcrt.dll
#1 0x005a6474 in typy_lookup_typename (type_name=0x0, block=0x0)
at ../../gdb/gdb/python/py-type.c:586
#2 0x005a66f3 in typy_lookup_type (demangled=0x5015a90, block=0x0)
at ../../gdb/gdb/python/py-type.c:650
#3 0x005a6867 in typy_legacy_template_argument (type=0x508f3a0, block=0x0,
argno=0) at ../../gdb/gdb/python/py-type.c:714
#4 0x005a6a09 in typy_template_argument (self=0x2d147b8, args=0x2d2c7d0)
at ../../gdb/gdb/python/py-type.c:759
#5 0x1e08883b in python27!PyCFunction_Call ()
from E:\code\common_bin\python27.dll
#6 0x1e0bf781 in python27!PyEval_GetFuncDesc ()
from E:\code\common_bin\python27.dll
#7 0x02d50080 in ?? ()
#8 0x1e1d57f8 in python27!PySuper_Type ()
from E:\code\common_bin\python27.dll
#9 0x00000001 in ?? ()
#10 0x02a4e684 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) frame 1
#1 0x005a6474 in typy_lookup_typename (type_name=0x0, block=0x0)
at ../../gdb/gdb/python/py-type.c:586
586 if (!strncmp (type_name, "struct ", 7))
(gdb) info locals
type = 0x0
except = {reason = 0, error = GDB_NO_ERROR, message = 0x0}
(gdb) info args
type_name = 0x0
block = 0x0
(gdb)
So, it looks like the crash is here:
\gdb\python\py-type.c
static struct type *
typy_lookup_typename (const char *type_name, const struct block *block)
{
struct type *type = NULL;
volatile struct gdb_exception except;
TRY_CATCH (except, RETURN_MASK_ALL)
{
if (!strncmp (type_name, "struct ", 7))
type = lookup_struct (type_name + 7, NULL);
else if (!strncmp (type_name, "union ", 6))
type = lookup_union (type_name + 6, NULL);
else if (!strncmp (type_name, "enum ", 5))
type = lookup_enum (type_name + 5, NULL);
else
type = lookup_typename (python_language, python_gdbarch,
type_name, block, 0);
}
if (except.reason < 0)
{
gdbpy_convert_exception (except);
return NULL;
}
return type;
}
It looks like the input argument "type_name" and "block" is all ZERO.
Any ideas?
Is it possible just add a condition check like:
if(type_name==0)
return NULL;
--------------------------------------------------------------------
BTW: if I build my test code under mingw gcc 4.6.2, then there's no crash here, and "p q" can correctly show the std::queue's contents from pretty printer.
BTW2: my friend xunxun can test the code under Win7, and it seems there's no crash.
asmwarrior
ollydbg from codeblocks' forum
next reply other threads:[~2011-10-30 13:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-30 13:30 asmwarrior [this message]
2011-10-30 18:17 ` asmwarrior
2011-10-31 8:50 ` 陳韋任
2011-10-31 8:52 ` asmwarrior
2011-10-31 9:42 ` xunxun
2011-11-01 1:46 ` asmwarrior
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=4EAD4FE7.9050102@gmail.com \
--to=asmwarrior@gmail.com \
--cc=gdb@sourceware.org \
--cc=xunxun1982@gmail.com \
/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