Subject: kern/24516: mmap not fully functional with smbfs
To: None <>
From: Lloyd Parkes <>
List: netbsd-bugs
Date: 02/22/2004 12:32:53
>Number:         24516
>Category:       kern
>Synopsis:       open/mmap/close doesn't work like it should
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 21 23:34:00 UTC 2004
>Originator:     Lloyd Parkes
>Release:        NetBSD 1.6ZH Jan 26 2004
Must Have Coffee
System: NetBSD 1.6ZH NetBSD 1.6ZH (Archangel) #0: Thu Feb 19 20:33:16 NZDT 2004 sparc64
Architecture: sparc64
Machine: sparc64

I have a program that opens a file, mmaps it and the closes it. The
mmaped data is then used. This program works if the file is on a local
file system, but not if the file is on a remote XP box. If I don't
close the file, then it all works as expected (until I run out of file
descriptors). The program fails with SIGSEGV as soon as tries to
access the mamped memory after the file is closed.


  fd = open (filename, O_RDONLY);
  fstat (fd, &sb);
  memory = mmap (NULL, sb.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0);
  close (fd);