Cannot set value to automatic variable when debuggin with gdb. Setting to an automatic variable cause "Error accessing memory address 0x???????: Bad address." message. How-To-Repeat: Debugging code below with gdb, I got error message and could not set value to the variable 'x'. ---------- test.c ---------- main(){ int x; x = 1; } ---------- test.c end---------- Above code is complied with: % cc -g -o test test.c Debugged with gdb: % gdb ./test It said: GDB is free software and you are welcome to distribute copies of it under certain conditions; type "show copying" to see the conditions. There is absolutely no warranty for GDB; type "show warranty" for details. GDB 4.16 (i386-unknown-freebsd), Copyright 1996 Free Software Foundation, Inc... (gdb) b main Breakpoint 1 at 0x163b: file test.c, line 3. (gdb) run Starting program: /a/steffi/export/yasu/./test Breakpoint 1, main () at test.c:3 3 x = 1; (gdb) n 4 } (gdb) set x = 100; Error accessing memory address 0xefbfd48c: Bad address. (gdb) quit The program is running. Quit anyway (and kill it)? (y or n) y --------------------------------------------------------------- If I define x as static, I can set value to x.
On Sep 09, 1997 at 03:17:20AM -0700, yasu@mrit.mei.co.jp wrote: > Breakpoint 1, main () at test.c:3 > 3 x = 1; > (gdb) n > 4 } > (gdb) set x = 100; > Error accessing memory address 0xefbfd48c: Bad address. Try this patch (courtesy of Bruce Evans): -- Jonathan ------------------------------ cut here ------------------------------ diff -c2 vm_map.c~ vm_map.c *** vm_map.c~ Mon Sep 1 18:00:38 1997 --- vm_map.c Wed Sep 10 14:02:48 1997 *************** *** 2288,2292 **** (entry->eflags & MAP_ENTRY_COW) == 0 || (entry->wired_count != 0)) { ! if ((fault_type & (prot)) != fault_type) RETURN(KERN_PROTECTION_FAILURE); } --- 2288,2293 ---- (entry->eflags & MAP_ENTRY_COW) == 0 || (entry->wired_count != 0)) { ! if ((fault_type & prot) != ! (fault_type & ~VM_PROT_OVERRIDE_WRITE)) RETURN(KERN_PROTECTION_FAILURE); }
State Changed From-To: open->closed Fix applied to vm_map.c, rev 1.90. Test case works with this patch.