Re: RFC: one approach to fixing PR 14100

Jan Kratochvil
2012-08-03T21:02:31Z

On Fri, 03 Aug 2012 18:02:59 +0200, Tom Tromey wrote:
> * dwarf2-frame.c (dwarf2_frame_cache): Set *this_cache at
> return only.
> * frame-unwind.h (frame_sniffer_ftype): Document prologue
> cache initialization constraint.

FYI I got now the assertion from ppc64 gdb.threads/watchpoint-fork.exp.
That is without this patch:

#5 0x00000000103e071c in internal_error (file=0x1065c308 "frame.c", line=2396, string=0x1065c2e8 "%s: Assertion `%s' failed.") at utils.c:882
#6 0x00000000103f12f4 in frame_cleanup_after_sniffer (arg=0x100106162f0) at frame.c:2396
#7 0x00000000101dcfc4 in do_my_cleanups (pmy_chain=0x1077cee8, old_chain=0x1060c5f0) at cleanups.c:155
#8 0x00000000101dd0b4 in do_cleanups (old_chain=0x1060c5f0) at cleanups.c:177
#9 0x0000000010279cf0 in throw_exception (exception=...) at exceptions.c:227
#10 0x00000000103f1fe4 in frame_unwind_find_by_frame (this_frame=0x100106162f0, this_cache=0x10010616308) at frame-unwind.c:123
(gdb) p ex
$2 = {reason = RETURN_ERROR, error = GENERIC_ERROR, message = 0x10010a00d50 "reading register r31 (#31): No such process."}

But with this patch it gets endless crashing loop, even on x86*, this is from
ppc64. This patch could not be x86* regression tested.

#43574 0x00000000103539a0 in dwarf2_frame_cache (this_frame=0x10012c9fc50, this_cache=0x10012c9fc68) at dwarf2-frame.c:1225
#43575 0x0000000010353bd0 in dwarf2_frame_prev_register (this_frame=0x10012c9fc50, this_cache=0x10012c9fc68, regnum=64) at dwarf2-frame.c:1270
#43576 0x00000000103ed22c in frame_unwind_register_value (frame=0x10012c9fc50, regnum=64) at frame.c:952
#43577 0x00000000103ecbd8 in frame_register_unwind (frame=0x10012c9fc50, regnum=64, optimizedp=0xfffe35daa88, unavailablep=0xfffe35daa8c, lvalp= 0xfffe35daa94, addrp=0xfffe35daa98, realnump=0xfffe35daa90, bufferp=0xfffe35dab48 "") at frame.c:858
#43578 0x00000000103ecfd0 in frame_unwind_register (frame=0x10012c9fc50, regnum=64, buf=0xfffe35dab48 "") at frame.c:912
#43579 0x00000000103ed748 in frame_unwind_register_unsigned (frame=0x10012c9fc50, regnum=64) at frame.c:1024
#43580 0x000000001007605c in rs6000_unwind_pc (gdbarch=0x10012cbbc90, next_frame=0x10012c9fc50) at rs6000-tdep.c:3111
#43581 0x00000000102981f4 in gdbarch_unwind_pc (gdbarch=0x10012cbbc90, next_frame=0x10012c9fc50) at gdbarch.c:2839
#43582 0x000000001035848c in dwarf2_tailcall_sniffer_first (this_frame=0x10012c9fc50, tailcall_cachep=0x10012c9fd40, entry_cfa_sp_offsetp=0xfffe35dae28) at dwarf2-frame-tailcall.c:387
#43583 0x00000000103539a0 in dwarf2_frame_cache (this_frame=0x10012c9fc50, this_cache=0x10012c9fc68) at dwarf2-frame.c:1225
#43584 0x00000000103542e0 in dwarf2_frame_sniffer (self=0x1064e840, this_frame=0x10012c9fc50, this_cache=0x10012c9fc68) at dwarf2-frame.c:1403
#43585 0x00000000103f1f88 in frame_unwind_find_by_frame (this_frame=0x10012c9fc50, this_cache=0x10012c9fc68) at frame-unwind.c:112

This is because dwarf2_tailcall_sniffer_first at the end of dwarf2_frame_cache
needs to have THIS_FRAME already finalized, therefore with the cache, as it
needs to access the previous (unwound) frame.

Thanks,
Jan