From nobody@FreeBSD.org  Mon Feb 16 13:28:30 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 8068016A4D2
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 16 Feb 2004 13:28:30 -0800 (PST)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7B40C43D2F
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 16 Feb 2004 13:28:30 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i1GLSU72051575
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 16 Feb 2004 13:28:30 -0800 (PST)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.10/8.12.10/Submit) id i1GLSUbC051559;
	Mon, 16 Feb 2004 13:28:30 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200402162128.i1GLSUbC051559@www.freebsd.org>
Date: Mon, 16 Feb 2004 13:28:30 -0800 (PST)
From: Dan van Pelt <dvp@chem.wwu.edu>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Use of mlockall(2) causes erratic behavior in subsequent programs
X-Send-Pr-Version: www-2.3

>Number:         62930
>Category:       kern
>Synopsis:       Use of mlockall(2) causes erratic behavior in subsequent programs
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    bms
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Feb 16 13:30:20 PST 2004
>Closed-Date:    Fri May 07 22:34:50 PDT 2004
>Last-Modified:  Fri May 07 22:34:50 PDT 2004
>Originator:     Dan van Pelt
>Release:        5.2.1-RC2
>Organization:
>Environment:
FreeBSD neutrino 5.2.1-RC2 FreeBSD 5.2.1-RC2 #0: Fri Feb 13 23:37:00 PST 2004     dan@neutrino:/usr/src/sys/i386/compile/NEUTRINO  i386
>Description:
A program which calls mlockall(2) without calling munlockall(2) before it exits seems to cause the OS to randomly deliver SIGBUS to other programs not only running in the shell that ran the original offending program but also in separate shells that are running under different UIDs.
>How-To-Repeat:
First, compile the following and run as root:

---------------------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>

int main (void)
{
  if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0)
    fprintf(stderr,"mlockall(2) failed.\n");

  return (0);
}
---------------------

At this point, subsequent commands issued to the shell will periodically and randomly fail with the following:

neutrino# ls
Bus error (core dumped)
neutrino#

You may have to run 'ls' (or another command) twenty or more times before the command finally fails.  I have tested this on other systems to verify that it wasn't my hardware.  The time (# of calls) that it takes the command to fail doesn't seem to vary much based on avail. memory, et al.
>Fix:
Making sure the application calls munlockall(2) before it exits seems to alleviate this behavior, but I'm not sure this is really a fix since AFAIK, the application shouldn't need to call munlockall(2) before exiting.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->bms 
Responsible-Changed-By: kris 
Responsible-Changed-When: Tue Feb 17 02:32:24 PST 2004 
Responsible-Changed-Why:  
bms wrote the mlockall() support 

http://www.freebsd.org/cgi/query-pr.cgi?pr=62930 

From: Brian Fundakowski Feldman <green@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, dvp@chem.wwu.edu
Cc:  
Subject: Re: kern/62930: Use of mlockall(2) causes erratic behavior in subsequent programs
Date: Mon, 26 Apr 2004 21:08:21 -0400

 I'm suffering from this problem quite a bit at work.  The pmap_extract() 
 that is called from vm_fault_unwire() fails.  I don't think you're even 
 allowed to call pmap_extract() and expect it to succeed.  We really need to 
 fix this one before 5.3.
 
 -- 
 Brian Fundakowski Feldman                           \'[ FreeBSD ]''''''''''\
   <> green@FreeBSD.org                               \  The Power to Serve! \
  Opinions expressed are my own.                       \,,,,,,,,,,,,,,,,,,,,,,\
 
 
State-Changed-From-To: open->closed 
State-Changed-By: alc 
State-Changed-When: Fri May 7 22:31:12 PDT 2004 
State-Changed-Why:  
vm/vm_map.c revision 1.334 corrects the principal problem reported 
herein; specify, problems resulting from the use of mlockall(2) 
without a munlockall(2) prior to exiting the process. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=62930 
>Unformatted:
