http://sourceware.org/ml/gdb-patches/2009-12/msg00364.html Subject: [patch] related_breakpoint stale ref crash fix Hi, getting occasional random: PASS: gdb.threads/local-watch-wrong-thread.exp: local watchpoint still triggers PASS: gdb.threads/local-watch-wrong-thread.exp: let thread_function0 return PASS: gdb.threads/local-watch-wrong-thread.exp: breakpoint on thread_function0's caller -PASS: gdb.threads/local-watch-wrong-thread.exp: local watchpoint automatically deleted +ERROR: Process no longer exists +UNRESOLVED: gdb.threads/local-watch-wrong-thread.exp: local watchpoint automatically deleted It is even reproducible on HEAD using "input" file below and: valgrind ../gdb -nx type == bp_none) return; [...] bpt->type = bp_none; xfree (bpt); } While fixing this part may be difficult I find the attached patch easy enough fixing the IMO currently most common crash due to it. No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. Thanks, Jan "input": set height 0 set width 0 set confirm no file ../testsuite/gdb.threads/local-watch-wrong-thread set can-use-hw-watchpoints 1 break main run break local-watch-wrong-thread.c:36 continue delete breakpoints watch *myp continue delete breakpoints echo MAKE watch\n watch *myp if trigger != 0 echo MAKE break\n break local-watch-wrong-thread.c:60 info break continue echo DELETE five\n delete 5 set trigger=1 continue set *myp=0 break local-watch-wrong-thread.c:47 continue 2009-12-23 Jan Kratochvil * breakpoint.c (delete_breakpoint related_breakpoint != NULL>): New. --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8649,6 +8649,16 @@ delete_breakpoint (struct breakpoint *bpt) if (bpt->type == bp_none) return; + /* At least avoid this stale reference until the reference counting of + breakpoints gets resolved. */ + if (bpt->related_breakpoint != NULL) + { + gdb_assert (bpt->related_breakpoint->related_breakpoint == bpt); + bpt->related_breakpoint->disposition = disp_del_at_next_stop; + bpt->related_breakpoint->related_breakpoint = NULL; + bpt->related_breakpoint = NULL; + } + observer_notify_breakpoint_deleted (bpt->number); if (breakpoint_chain == bpt)