Subject: port-i386/1834: panic caused by mlock system call on i386
To: None <gnats-bugs@gnats.netbsd.org>
From: R.Gopalakrishnan <gopal@yikes.ccrc.wustl.edu>
List: netbsd-bugs
Date: 12/13/1995 10:30:07
>Number: 1834
>Category: port-i386
>Synopsis: The mlock system call panics in pmap_enter()
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: gnats-admin (GNATS administrator)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Dec 13 12:20:03 1995
>Last-Modified:
>Originator: gopal
>Organization:
Washington University, St.Louis
>Release: NetBSD 1.1_ALPHA
>Environment:
Pentium 133 Mhz PC, NetBSD 1.1_ALPHA,
system: NetBSD far-superior.ccrc.wustl.edu 1.1_ALPHA NetBSD 1.1_ALPHA (FARS) #22: Tue Dec 12 17:46:54 CST 1995 root@far-superior.ccrc.wustl.edu:/usr/src/sys/arch/i386/compile/FARS i386
>Description:
I tried to mlock an address obtained using shmat. The machine panics
in pmap_enter(). I am running as root. If I try to mlock an address
obtained using malloc, it succeeds.
>How-To-Repeat:
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#define N 200
main()
{
int sid ;
char *ptr ;
/* Create a segment with key 0x5555 */
if ((sid = shmget(0x5555, N*4096, (IPC_CREAT|SHM_RND)|(0666))) < 0) {
perror("shmget") ;
exit(1) ;
}
printf("sid=0x%x\n",sid) ; /* succeeds;gives sid of 0x30000 */
/* Attach it to my process */
if ((ptr = (char *)shmat(sid, 0, 0600)) < (char *)0) {
perror("shmat") ;
exit(1) ;
}
printf("addr=0x%x\n",ptr) ;/* succeeds; returns 0x10801000 */
/* THIS CALL PANICS in pmap_enter() saying "ptdi 0xXXXXX" */
if (mlock(ptr, 4096)) perror("mlock") ;
>Fix:
Before calling mlock, read or write the first byte in each page that
you want to lock. Then the mlock call succeeds without panic.
>Audit-Trail:
>Unformatted: