NetBSD Problem Report #8533

Received: (qmail 616 invoked from network); 2 Oct 1999 12:53:30 -0000
Message-Id: <199910021253.OAA03298@lyssa.zhadum.de>
Date: Sat, 2 Oct 1999 14:53:10 +0200 (CEST)
From: tron@netbsd.org (Matthias Scheler)
Reply-To: tron@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: memory not accessable after successful mmap()
X-Send-Pr-Version: 3.95

>Number:         8533
>Category:       port-i386
>Synopsis:       memory not accessable after successful mmap()
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-i386-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 02 06:05:01 +0000 1999
>Closed-Date:    Mon Oct 04 18:05:27 +0000 1999
>Last-Modified:  Mon Oct 04 18:06:10 +0000 1999
>Originator:     Matthias Scheler
>Release:        991001
>Organization:
Matthias Scheler                            http://www.sighardstrasse.de/~tron/
>Environment:
System: NetBSD lyssa.zhadum.de 1.4K NetBSD 1.4K (LYSSA) #0: Fri Oct 1 14:18:55 CEST 1999 tron@lyssa.zhadum.de:/src/sys/compile/LYSSA i386


>Description:
On i386 mmap()ing a high memory are (>= 0xee000000) succeeds but the memory
cannot be accessed afterwards.

>How-To-Repeat:
Compile and execute this program "mmap.c":

/*

	$Id: mmap.c,v 1.6 1999/10/02 12:47:47 tron Exp $

*/

#include <sys/types.h>
#include <sys/param.h>
#include <sys/mman.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#ifndef MAP_FAILED	/* for NetBSD 1.3 */
#define MAP_FAILED (void *)-1
#endif

int main(int argc,char **argv)

{
 int Opt;
 char *Addr,*EndPtr;
 quad_t Value;
 size_t Length,Index;

 Addr=NULL;
 Length=getpagesize();

 while ((Opt=getopt(argc,argv,"a:l:"))!=-1)
  switch (Opt)
   {
    case 'a':
     Value=strtoq(optarg,&EndPtr,0);
     if (EndPtr!=optarg) Addr=(char *)((unsigned long)Value);
     break;
    case 'l':
     Value=strtoq(optarg,&EndPtr,0);
     if (EndPtr!=optarg) Length=(size_t)Value;
     break;
    default:
     (void)fprintf(stderr,"Usage: %s [-a address] [-l length]\n",argv[0]);
     return EXIT_FAILURE;
   }

 (void)printf("Trying to map %d bytes at %p\n",Length,Addr);
 if ((Addr=mmap(Addr,
                Length,
                PROT_READ|PROT_WRITE|PROT_EXEC,
                MAP_PRIVATE|MAP_ANON|((Addr!=NULL)?MAP_FIXED:0),
                -1,
                0))==MAP_FAILED)
  {
   perror("mmap");
   return EXIT_FAILURE;
  }
 (void)printf("Mapped %d bytes at %p\n",Length,Addr);

 for (Index=0; Index<Length; Index++)
  Addr[Index]=42;

 (void)puts("Test completed.");

 return EXIT_SUCCESS;
}

tron@lyssa:~>./mmap 
Trying to map 4096 bytes at 0x0
Mapped 4096 bytes at 0x480d7000
Test completed.
tron@lyssa:~>./mmap -a 0xed000000
Trying to map 4096 bytes at 0xed000000
Mapped 4096 bytes at 0xed000000
Test completed.
tron@lyssa:~>./mmap -a 0xee000000
Trying to map 4096 bytes at 0xee000000
Mapped 4096 bytes at 0xee000000
Segmentation fault

I can reproduce this problem unter NetBSD 1.3.2, 1.4.1 and current.

>Fix:
None given.
>Release-Note:
>Audit-Trail:

From: "Dr. Lex Wennmacher" <wennmach@geo.Uni-Koeln.DE>
To: Matthias Scheler <tron@netbsd.org>
Cc: gnats-bugs@gnats.netbsd.org,
        "Dr. Lex Wennmacher" <wennmach@pluto.geo.Uni-Koeln.DE>
Subject: Re: port-i386/8533: memory not accessable after successful mmap()
Date: Sun, 3 Oct 1999 23:21:43 +0200

 Hi tron,

 hmm, I can't seem to reproduce the problem, at least not on my 1.4 i386
 machine:

 hal:~/NetBSD >uname -a
 NetBSD hal 1.4 NetBSD 1.4 (HAL) #4: Wed Sep 29 17:10:27 MEST 1999     wennmach@hal:/usr/src/sys/arch/i386/compile/HAL i386
 hal:~/NetBSD >./mmap -a 0xed000000
 Trying to map 4096 bytes at 0xed000000
 Mapped 4096 bytes at 0xed000000
 Test completed.
 hal:~/NetBSD >./mmap -a 0xee000000
 Trying to map 4096 bytes at 0xee000000
 Mapped 4096 bytes at 0xee000000
 Test completed.
 hal:~/NetBSD >./mmap -a 0xef000000
 Trying to map 4096 bytes at 0xef000000
 Mapped 4096 bytes at 0xef000000
 Test completed.

 Maybe the problem is processor-related? My machine has a Cyrix 5x86 MP100,
 which is a i486-class CPU.

 Cheers
 Lex
State-Changed-From-To: open->closed 
State-Changed-By: fvdl 
State-Changed-When: Mon Oct 4 11:05:27 PDT 1999 
State-Changed-Why:  
Fixed by changing a sometimes erroneous check for the stack limit in 
the i386 page fault handler. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.