From nobody  Fri Sep 12 03:17:20 1997
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.7/8.8.7) id DAA22884;
          Fri, 12 Sep 1997 03:17:20 -0700 (PDT)
Message-Id: <199709121017.DAA22884@hub.freebsd.org>
Date: Fri, 12 Sep 1997 03:17:20 -0700 (PDT)
From: yasu@mrit.mei.co.jp
To: freebsd-gnats-submit@freebsd.org
Subject: Cannot debug with gdb with message 'Error accessing memory address'
X-Send-Pr-Version: www-1.0

>Number:         4517
>Category:       gnu
>Synopsis:       Cannot debug with gdb with message 'Error accessing memory address'
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 12 03:20:01 PDT 1997
>Closed-Date:    Fri Sep 12 09:39:06 PDT 1997
>Last-Modified:  Fri Sep 12 09:47:50 PDT 1997
>Originator:     Yasuhiko Watanabe
>Release:        FreeBSD 3.0-CURRENT
>Organization:
Matsushita Research Institute Tokyo, Inc.
>Environment:
FreeBSD waltz 3.0-CURRENT FreeBSD 3.0-CURRENT #0: Fri Sep  5 16:57:09 JST 1997     yasu@waltz:/usr/src/sys/compile/SMALL  i386

>Description:
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.

>Fix:

>Release-Note:
>Audit-Trail:

From: Jonathan Lemon <jlemon@americantv.com>
To: yasu@mrit.mei.co.jp
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: gnu/4517: Cannot debug with gdb with message 'Error accessing memory address'
Date: Fri, 12 Sep 1997 09:16:14 -0500

 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 
State-Changed-By: jlemon 
State-Changed-When: Fri Sep 12 09:39:06 PDT 1997 
State-Changed-Why:  

Fix applied to vm_map.c, rev 1.90.  Test case works with this patch. 
>Unformatted:
