This is the mail archive of the
mailing list for the GDB project.
Re: bfinish writes to random addresses.
Daniel Jacobowitz wrote:
On Tue, Jul 25, 2006 at 04:39:15PM +0100, Greg Law wrote:
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.
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
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.
Greg Law, Undo Software http://undo-software.com/