*BSD News Article 69316


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.wildstar.net!imci5!pull-feed.internetmci.com!news.internetMCI.com!newsfeed.internetmci.com!swrinde!howland.reston.ans.net!Germany.EU.net!Dortmund.Germany.EU.net!interface-business.de!usenet
From: j@ida.interface-business.de (J Wunsch)
Newsgroups: comp.unix.bsd.misc
Subject: Re: Why does this program panic 4.4BSD?
Date: 24 May 1996 13:52:01 GMT
Organization: interface business GmbH, Dresden
Lines: 61
Message-ID: <4o4eu1$mr6@innocence.interface-business.de>
References: <4o2kn3$21u@panix2.panix.com>
Reply-To: joerg_wunsch@interface-business.de (Joerg Wunsch)
NNTP-Posting-Host: ida.interface-business.de
X-Newsreader: knews 0.9.6
X-Phone: +49-351-31809-14
X-Fax: +49-351-3361187
X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F  93 21 E0 7D F9 12 D6 4E

tls@panix.com (Thor Lancelot Simon) wrote:

> The following code appears to quite reliably panic every 4.4 derivative I've
> run it on, when run by an ordinary, unprivileged user.

Your code wasn't compilable on my FreeBSD system (several header files
are also required when _not_ using SunOS -- i wonder how you got it to
find O_RDONLY on your other 4.4BSD derivatives?), but the following
works fine for me:

j@ida 664% uname -a
FreeBSD ida.interface-business.de 2.2-current FreeBSD 2.2-current\
 #0: Tue May 21 13:43:20 MET DST 1996\
     j@ida.interface-business.de:/usr/src/sys/compile/IDA  i386
j@ida 665% cat foo.c
#define MEGS 4

#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/mman.h>

int
main(void) {
        int i; caddr_t c;
 
        c = mmap(0, (MEGS * 1024 * 1024), PROT_READ, MAP_SHARED,
                open("/dev/zero", O_RDONLY), 0 );
        while(1) {
                for(i = 0; i < MEGS; i++) {
                        if(i != 0)
                                munlock(c + (i - 1) * 1024 * 1024,
                                        1 * 1024 * 1024);
                        mlock(c + i * 1024 * 1024, (1 * 1024 * 1024));
                        sleep(1);
                }
        }
}
j@ida 666% cc -Wall -O foo.c
j@ida 667% ./a.out
^Z
Suspended
j@ida 668% bg
[1]    ./a.out &
j@ida 669% ps -l
  UID   PID  PPID CPU PRI NI   VSZ  RSS WCHAN  STAT  TT       TIME COMMAND
  107   362   361   1  18  0   940  732 pause  Ss    p4    0:10.55 -tcsh (tcsh)
  107 13668   362   0  18  0   136  444 pause  S     p4    0:00.02 ./a.out
  107 13669   362   4  29  0   456  288 -      R+    p4    0:00.01 ps -l
j@ida 670% ps -l
  UID   PID  PPID CPU PRI NI   VSZ  RSS WCHAN  STAT  TT       TIME COMMAND
  107   362   361   0  18  0   940  732 pause  Ss    p4    0:10.57 -tcsh (tcsh)
  107 13668   362   0  18  0   136  444 pause  S     p4    0:00.02 ./a.out
  107 13670   362   2  28  0   456  288 -      R+    p4    0:00.01 ps -l
j@ida 671% kill %1
[1]    Terminated                    ./a.out

-- 
J"org Wunsch					       Unix support engineer
joerg_wunsch@interface-business.de       http://www.interface-business.de/~j