Re: [PATCH] Seg fault whilst stepping when watch set [ping!] [in breakpoint.c]

David Lecomber
2004-11-03T12:08:23Z

Hi Eli,

Breakpoint 1, 0x08089e8a in main ()
(gdb) step
Single stepping until exit from function main,
which has no line number information.
sample () at f90demo.f90:72
72 CALL MPI_INIT(ierr)
Current language: auto; currently fortran
(gdb) watch i
Hardware watchpoint 2: i
(gdb) n
Error in re-setting breakpoint 2:
No symbol "i" in current context.

{seg fault...} and in the other GDB:
Program received signal SIGSEGV, Segmentation fault.
evaluate_subexp (expect_type=0x0, exp=0x0, pos=0xbfffef34,
noside=EVAL_NORMAL) at eval.c:71
71 return (*exp->language_defn->la_exp_desc->evaluate_exp)

#0 evaluate_subexp (expect_type=0x0, exp=0x0, pos=0xbfffef34,
noside=EVAL_NORMAL) at eval.c:71
#1 0x080d3fa9 in evaluate_expression (exp=0x0) at eval.c:161
#2 0x080c4341 in insert_bp_location (bpt=0x82d8458,
tmp_error_stream=0x82de608, disabled_breaks=0xbfffefd0,
process_warning=0xbfffefd4,
hw_breakpoint_error=0xbfffefd8) at breakpoint.c:949
#3 0x080c45a7 in insert_breakpoints () at breakpoint.c:1149
#4 0x080f43cd in keep_going (ecs=0xbffff0d0) at infrun.c:2716
#5 0x080f2f47 in handle_inferior_event (ecs=0xbffff0d0) at
infrun.c:2543
#6 0x080f270b in wait_for_inferior () at infrun.c:991
#7 0x080f253d in proceed (addr=1, siggnal=TARGET_SIGNAL_DEFAULT,
step=1) at infrun.c:814
#8 0x080efe9b in step_1 (skip_subroutines=1, single_inst=0,
count_string=0x0) at infcmd.c:688

(gdb) p exp
$1 = (struct expression *) 0x0

Looking at frame 2:

#2 0x080c4341 in insert_bp_location (bpt=0x82d8458,
tmp_error_stream=0x82de608, disabled_breaks=0xbfffefd0,
process_warning=0xbfffefd4,
hw_breakpoint_error=0xbfffefd8) at breakpoint.c:949
949 v = evaluate_expression (bpt->owner->exp);

(gdb) p *bpt
$5 = {next = 0x82de5d8, loc_type = bp_loc_hardware_watchpoint, owner =
0x835f3f0, inserted = 0 '\0', duplicate = 0 '\0', address = 0, section =
0x0,
shadow_contents = '\0' <repeats 15 times>, requested_address = 0}
(gdb) p *(bpt->owner)
$6 = {next = 0x83ac680, type = bp_hardware_watchpoint, enable_state =
bp_enabled, disposition = disp_donttouch, number = 2, loc = 0x82d8458,
line_number = 0,
source_file = 0x0, silent = 0 '\0', ignore_count = 0, commands = 0x0,
frame_id = {stack_addr = 0, code_addr = 0, special_addr = 0,
stack_addr_p = 0,
code_addr_p = 0, special_addr_p = 0}, cond = 0x0, addr_string = 0x0,
language = language_fortran, input_radix = 10, cond_string = 0x0,
exp_string = 0x835d408 "i",
exp = 0x0, exp_valid_block = 0x841723c, val = 0x835f8d8, val_chain =
0x0, related_breakpoint = 0x83ac680, watchpoint_frame = {stack_addr =
3221223780,
code_addr = 134526326, special_addr = 0, stack_addr_p = 1,
code_addr_p = 1, special_addr_p = 0}, thread = -1, hit_count = 0,
dll_pathname = 0x0,
triggered_dll_pathname = 0x0, forked_inferior_pid = 0, exec_pathname =
0x0, ops = 0x0, from_tty = 0, flag = 0, pending = 0}

So bpt->owner->exp is clearly null, which makes it a bad idea to
evaluate it ;-)

> If the binary is short, then you could alternatively mail it to me as
> a binary attachment together with the source and instructions how to
> reproduce the crash.

Curiously on Fedora 2 I get a seg fault, and

Error in re-setting breakpoint 2:
No symbol "i" in current context.

But on Redhat 9, I get no segfault but do see the above error repeated 3
times..

With my patch, it works fine, for me ;-)

d.