From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23095 invoked by alias); 30 Oct 2011 13:21:21 -0000 Received: (qmail 23084 invoked by uid 22791); 30 Oct 2011 13:21:19 -0000 X-SWARE-Spam-Status: No, hits=0.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KAM_STOCKTIP,RCVD_IN_DNSWL_LOW,TW_DB,TW_NX X-Spam-Check-By: sourceware.org Received: from mail-iy0-f169.google.com (HELO mail-iy0-f169.google.com) (209.85.210.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 30 Oct 2011 13:21:04 +0000 Received: by iagf6 with SMTP id f6so8063136iag.0 for ; Sun, 30 Oct 2011 06:21:03 -0700 (PDT) Received: by 10.42.136.196 with SMTP id v4mr16034959ict.3.1319980861536; Sun, 30 Oct 2011 06:21:01 -0700 (PDT) Received: from [192.168.1.102] ([115.195.157.152]) by mx.google.com with ESMTPS id p16sm21813552ibk.6.2011.10.30.06.20.53 (version=SSLv3 cipher=OTHER); Sun, 30 Oct 2011 06:21:00 -0700 (PDT) Message-ID: <4EAD4FE7.9050102@gmail.com> Date: Sun, 30 Oct 2011 13:30:00 -0000 From: asmwarrior User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: gdb@sourceware.org CC: Xun Xun Subject: gdb crash when I try to print a std::queue (Windows) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-10/txt/msg00227.txt.bz2 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 #include #include #include #include #include #include #include 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 m; m[0] = "000"; m[1] = "111"; wxString& wxStrRef = wxStr; wxStrRef += L" Ref"; std::string& stdStrRef = stdStr; stdStrRef += " Ref"; std::list l = {"a", "b", "c"}; std::vector v = {"a", "b", "c"}; std::queue q; q.push("a"); q.push("b"); std::stack 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 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: ... 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 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: . (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