stop using mmap for zip I/O

Xueming Shen xueming.shen at oracle.com
Thu Feb 26 22:32:26 UTC 2015


On 02/26/2015 02:17 PM, christos at zoulas.com wrote:
> Hi,
>
> There are numerous bug reports about the jvm crashing in libzip...
> Just google for "libzip java crash". The bottom line is that using
> mmap is problematic (I can get into more per OS details if necessary)
> because it will potentially signal when the file size is altered.
> Can we please turn USE_MMAP off, and/or remove the code (zip_util.c)?
> I don't think it is acceptable for the jvm to crash if it tries to
> read a file while it is being modified. The following simple program
> demonstrates the issue... just:
>
That's true, unfortunately, the mmap does trigger crash here and there....

There is a property you can define to disable it in later releases
-Dsun.zip.disableMemoryMapping=true

There is discussion that maybe we should simply disable the mmap by default ...

And, there is further plan to simply move the general zip file handling up to
pure java, without any native code, as the webrev showed below. I'm still
hoping we can do it in jdk9 later, when everyone is not that busy and can
help codereview the change. (the webrev might be a little aged)

-Sherman

--------------------------------------------------------------------
Hi,

This one didn't make into jdk8. Here is an updated webrev for the jdk9 repo

http://cr.openjdk.java.net/~sherman/zipfile_j/webrev

And a pure java version of j.u.ZipFile is also available at

http://cr.openjdk.java.net/~sherman/zipfile_jj/webrev/

We do have incident reports and requests that suggest a pure Java version
of j.u.ZipFile might be preferred, especially to eliminate the possibility of
jvm crash at native level, mostly triggered by the mmap usage and/or use
scenario that the target zip/jar file is being overwritten while reading.

And java implementation also brings in the benefits of better memory usage
(all memory allocated in java heap), no more expensive jni invocations...

Opinion/comments are appreciated.

Thanks!
-Sherman
---------------------------------------------------------------------



More information about the core-libs-dev mailing list