From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32299 invoked by alias); 7 Jan 2010 17:51:12 -0000 Received: (qmail 32289 invoked by uid 22791); 7 Jan 2010 17:51:10 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Jan 2010 17:51:05 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o07Hp4v1003725 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 7 Jan 2010 12:51:04 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o07HovBS026597 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 7 Jan 2010 12:51:00 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id o07HovrD015394 for ; Thu, 7 Jan 2010 18:50:57 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o07HosNu015389 for gdb-patches@sourceware.org; Thu, 7 Jan 2010 18:50:54 +0100 Date: Thu, 07 Jan 2010 17:51:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] Fix crash reading broken stabs Message-ID: <20100107175054.GA15215@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Mutt/1.5.20 (2009-08-17) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-01/txt/msg00142.txt.bz2 Hi, seen this stabs from unknown variant of gcc-4.1.2: 1176586 LSYM 0 154 00000000 16682076 basic_string,std::allocator >::_Rep:Tt(0,34)=3Ds12!1,020,(0,35)=3Dxs_= Rep_base:;_S_max_size:/2(0,36)=3Dk(0,30):_ZNSs4_Rep11_S_max_sizeE;_S_termin= al:/2(0,22):_ZNSs4_Rep11_S_terminalE;_S_empty_rep_storage:/2(0,37)=3Dar(0,3= 8)=3Dr(0,38);0;037777777777;;0;3;(0,30):_ZNSs4_Rep20_S_empty_rep_storageE;_= S_empty_rep::(0,39)=3Df(0,40)=3D&(0,34):_ZNSs4_Rep12_S_empty_repEv;2A?;_M_i= s_leaked::(0,41)=3D#(0,34),(0,42)=3D@s8;-16;,(0,43)=3D*(0,44)=3Dk(0,34),(0,= 1);:_ZNKSs4_Rep12_M_is_leakedEv;2B.;_M_is_shared::(0,41):_ZNKSs4_Rep12_M_is= _sharedEv;2B.;_M_set_leaked::(0,45)=3D#(0,34),(0,1),(0,33),(0,1);:_ZNSs4_Re= p13_M_set_leakedEv;2A.;_M_set_sharable::(0,45):_ZNSs4_Rep15_M_set_sharableE= v;2A.;_M_set_length_and_sharable::(0,46)=3D#(0,34),(0,1),(0,33),(0,25),(0,1= );:_ZNSs4_Rep26_M_set_length_and_sharableEj;2A.;_M_refdata::(0,47)=3D#(0,34= ),(0,3),(0,33),(0,1);:_ZNSs4_Rep10_M_refdataEv;2A.;_M_grab::(0,48)=3D#(0,34= ),(0,3),(0,33),(0,5),(0,5),(0,1);:_ZNSs4_Rep7_M_grabERKSaIcES2_;2A.;_S_crea= te::(0,49)=3Df(0,33):_ZNSs4_Rep9_S_createEjjRKSaIcE;2A?;_M_dispose::(0,50)= =3D#(0,34),(0,1),(0,33),(0,5),(0,1);:_ZNSs4_Rep10_M_disposeERKSaIcE;2A.;_M_= destroy::(0,51)=3D#(0,34),(0,1),(0,33),(0,5),(0,1);:_ZNSs4_Rep10_M_destroyE= RKSaIcE;2A.;_M_refcopy::(0,47):_ZNSs4_Rep10_M_refcopyEv;2A.;_M_clone::(0,52= )=3D#(0,34),(0,3),(0,33),(0,5),(0,25),(0,1);:_ZNSs4_Rep8_M_cloneERKSaIcEj;2= A.;; There is a GDB crash at: _M_is_leaked::(0,41)=3D#(0,34),(0,42)=3D@s8;-16;,(0,43)=3D*(0,44)=3Dk(0,34)= ,(0,1); ^^ + [...] Some broken stabs + output contained `(0,41),(0,42)=3D@s8;-16;,(0,43),(0,1);' where should + have been present ";-16,(0,43)" reference instead. This way the + excessive ";" marker prematurely stops the parameters parsing. */ Still I was unable to reproduce producing such STABS output. So this patch does not try to compensate the - presumably - buggy STABS out= put and parses such record incorrectly. But it no longer crashes. No regressions on {x86_64-m32,i686}-fedora12-linux-gnu using --target_board unix/-gstabs+/-m32. Thanks, Jan gdb/ 2010-01-07 Jan Kratochvil * stabsread.c (read_args): Handle zero arguments. gdb/testsuite/ 2010-01-07 Jan Kratochvil * gdb.stabs/weird.def (args93): New. --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -4111,7 +4111,17 @@ read_args (char **pp, int end, struct objfile *objfi= le, int *nargsp, } (*pp)++; /* get past `end' (the ':' character) */ =20 - if (TYPE_CODE (types[n - 1]) !=3D TYPE_CODE_VOID) + if (n =3D=3D 0) + { + /* We should read at least the THIS parameter here. Some broken sta= bs + output contained `(0,41),(0,42)=3D@s8;-16;,(0,43),(0,1);' where should + have been present ";-16,(0,43)" reference instead. This way the + excessive ";" marker prematurely stops the parameters parsing. */ + + complaint (&symfile_complaints, _("Invalid (empty) method arguments"= )); + *varargsp =3D 0; + } + else if (TYPE_CODE (types[n - 1]) !=3D TYPE_CODE_VOID) *varargsp =3D 1; else { --- a/gdb/testsuite/gdb.stabs/weird.def +++ b/gdb/testsuite/gdb.stabs/weird.def @@ -880,3 +880,6 @@ var3: .stabs "sym92:\ !#$%&'()*+,-./0123456789:;<=3D>?@ABCDEFGHIJKLMNOPQRSTUVWXY= Z[]^_`abcdefghijklmnopqrstuvwxyz{|}~",N_LSYM,0,0,0 .stabs "type92:t92=3D\ !#$%&'()*+,-./0123456789:;<=3D>?@ABCDEFGHIJKLMNOPQR= STUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~",N_LSYM,0,0,0 .stabs "attr92:G392=3D@\ !#$%&'()*+,-./0123456789:<=3D>?@ABCDEFGHIJKLMNOPQ= RSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~;1",N_GSYM,0,0, 0 + +# See read_args "Invalid (empty) method arguments" error. +.stabs "args93:G93=3D#(0,93),(0,93)=3D@s8;-16;,(0,93),(0,93);",N_GSYM,0,0,0