public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/13363] New: gdb crash when I try to print a std::queue in python pretty printer
@ 2011-10-31  8:48 asmwarrior at gmail dot com
  2011-10-31 11:42 ` [Bug python/13363] " pmuldoon at redhat dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: asmwarrior at gmail dot com @ 2011-10-31  8:48 UTC (permalink / raw)
  To: gdb-prs

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

             Bug #: 13363
           Summary: gdb crash when I try to print a std::queue in python
                    pretty printer
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: python
        AssignedTo: unassigned@sourceware.org
        ReportedBy: asmwarrior@gmail.com
    Classification: Unclassified


Hi,I'm bulding a cvs head gdb 2011-10-30 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]={"&amp;","&lt;","&gt;","&quot;","&apos;"};


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.

BTW: If I use a gdb 2011-10-27 build, then there is no such crash. So, I guess
it was a regression in 2011-10-27 to 2011-10-30.

Thanks.
asmwarrior

PS: I originally wrote a post in gdb maillist, see:
http://sourceware.org/ml/gdb/2011-10/msg00226.html

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

end of thread, other threads:[~2011-11-04 12:09 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-31  8:48 [Bug python/13363] New: gdb crash when I try to print a std::queue in python pretty printer asmwarrior at gmail dot com
2011-10-31 11:42 ` [Bug python/13363] " pmuldoon at redhat dot com
2011-10-31 12:35 ` pmuldoon at redhat dot com
2011-10-31 12:45 ` pmuldoon at redhat dot com
2011-10-31 14:35 ` asmwarrior at gmail dot com
2011-10-31 14:57 ` pmuldoon at redhat dot com
2011-11-01  1:41 ` asmwarrior at gmail dot com
2011-11-01  5:00 ` xunxun1982 at gmail dot com
2011-11-01  8:31 ` pmuldoon at redhat dot com
2011-11-01 11:26 ` pmuldoon at redhat dot com
2011-11-01 11:28 ` pmuldoon at redhat dot com
2011-11-01 11:58 ` asmwarrior at gmail dot com
2011-11-01 12:56 ` asmwarrior at gmail dot com
2011-11-04 11:57 ` cvs-commit at gcc dot gnu.org
2011-11-04 12:09 ` 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).