Subject: kern/32769: Linux emulation doesn't support mmap with MAP_NORESERVE
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Brian de Alwis <bsd@cs.ubc.ca>
List: netbsd-bugs
Date: 02/07/2006 20:15:01
>Number:         32769
>Category:       kern
>Synopsis:       Linux emulation doesn't support mmap with MAP_NORESERVE
>Confidential:   no
>Severity:       critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 07 20:15:00 +0000 2006
>Originator:     Brian de Alwis
>Release:        NetBSD 3.0_STABLE
>Organization:
  Brian de Alwis | Software Practices Lab | UBC | http://www.cs.ubc.ca/~bsd/
>Environment:
System: NetBSD slab 3.0_STABLE NetBSD 3.0_STABLE (SLAB) #18: Mon Jan 30 13:38:11 PST 2006 bsd@slab:/usr/src/src-3.0/sys/arch/i386/compile/SLAB i386
Architecture: i386
Machine: i386

Also tried a kernel from -current compiled from yesterday's tar_files,
to no avail.
>Description:

I'm unable to get BEA's JRockit 5 to run on NetBSD/i386 3.0 as its
applications fail with memory errors:

    $ ktrace /usr/local/installs/JRockit5-R26/bin/jar
    [JRockit] ERROR:  Fatal error in JRockit during memory setup phase.
    Try to reduce the heap size using -Xmx:<size>m, i.e. "-Xmx:16m".
    Could not create the Java virtual machine.

Running using a kernel compiled with DEBUG_LINUX, I see the following
output:

    [...]
    old_mmap(0, 4096, 3, 34, -1, 0)
    old_mmap(0, 8192, 0, 50, -1, 0)
    old_mmap(0, 16384, 3, 34, -1, 0)
    old_mmap(0, 16384, 3, 34, -1, 0)
    old_mmap(0, 16384, 3, 34, -1, 0)
    old_mmap(0xc0000000, 65536, 0, 34, -1, 0)
    old_mmap(0x8100000, 200978432, 0, 16418, -1, 0)
    [JRockit] ERROR:  Fatal error in JRockit during memory setup phase.
    Try to reduce the heap size using -Xmx:<size>m, i.e. "-Xmx:16m".
    Could not create the Java virtual machine.

The length of that last old_mmap() is 200MB.  Increasing the data
limits to 500MB, it fails with yet another call to mmap.  Consulting
the linux mmap(2) flags, 16418 corresponds to MAP_NORESERVE |
MAP_ANONYMOUS | MAP_PRIVATE -- and from my poking around, NetBSD's
mmap doesn't seem to implement MAP_NORESERVE.

As all the apps shipped with JRockit exhibit this behaviour, I'm
guessing it's some library they're using, and I suspect that future
Linux apps might have the same issues.  Would adding equivalent
support to NetBSD be difficult?

I tried running a -current kernel with no difference.

>How-To-Repeat:
Download JRockit <http://dev2dev.bea.com/jrockit/> and begin the
install.  The installation fails as it tries to run the JRockit JVM
as part of the install, which fails as above.  Suspend the install after
it has finished extracting all files and poke around in /tmp/file*
for the files -- the SDK is in linux_ia32_jrockit150_04_sdk.zip, which
you can extract somewhere else.  Try running ../bin/jar.

>Fix:
	Sorry, unknown.