From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24622 invoked by alias); 25 Jul 2006 16:01:41 -0000 Received: (qmail 24606 invoked by uid 22791); 25 Jul 2006 16:01:40 -0000 X-Spam-Check-By: sourceware.org Received: from client1.solarflare.com (HELO solar008.SolarFlarecom.com) (216.237.3.222) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 25 Jul 2006 16:01:37 +0000 Received: from OCEX01.SolarFlarecom.com ([10.20.40.32]) by solar008.SolarFlarecom.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 25 Jul 2006 09:01:36 -0700 Received: from [10.17.20.19] ([10.17.20.19]) by OCEX01.SolarFlarecom.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 25 Jul 2006 09:01:34 -0700 Message-ID: <44C6405A.50502@undo-software.com> Date: Tue, 25 Jul 2006 16:09:00 -0000 From: Greg Law User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc3 (X11/20050929) MIME-Version: 1.0 To: Daniel Jacobowitz CC: gdb@sourceware.org Subject: Re: bfinish writes to random addresses. References: <44C63B23.7060306@undo-software.com> <20060725154115.GA13191@nevyn.them.org> In-Reply-To: <20060725154115.GA13191@nevyn.them.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-07/txt/msg00177.txt.bz2 Daniel Jacobowitz wrote: > On Tue, Jul 25, 2006 at 04:39:15PM +0100, Greg Law wrote: > >>Hi list, >> >>When doing a 'finish' command when EBP contains bad values such that gdb >>gets confused about a function's return address, it writes a breakpoint >>into an essentially random point in the inferior's address space. >> >>Should I report a bug, or do we consider it the user's own stupid fault >>if he/she tries to do a 'finish' command when the frame-pointer is invalid? > > > Well, is there anything better that could be done about it? I guess one option would be to use a hardware breakpoint when setting breakpoints based on such "derived" addresses. At least that way it's non-destructive if gdb gets it wrong. Having gdb check the return address looks like a sensible code address might also be worthwhile. Of course this will not fix all cases, especially if the calculated return address happens to point into the middle of an instruction. But hopefully in reality most things that look like pointers to code will actually be pointers to code, and so properly aligned, and the breakpoint will just go to the wrong place, rather than clobbering random data. > I don't > think so. Finish is going to take you back to whatever GDB thinks the > previous frame is. > > Now, of course, GDB shouldn't get confused in the first place. That's > always worth filing a bug about, although it may be a case of > inadequate debug information or other similar problems out of our > control. In the particular case I'm looking at I think it's reasonable that gdb gets the return address wrong. It's some assembler code that clobbers EBP. My concern was more gdb's ability to clobber arbitrary inferior addresses, and the subtle problems this might lead to. g -- Greg Law, Undo Software http://undo-software.com/