[GRADLE-3370] Continuous build crashes the JVM of the Gradle Scala Zinc compiler daemon Created: 09/Dec/15  Updated: 09/Dec/15  Resolved: 09/Dec/15

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 2.11-rc-1

Type: Bug
Reporter: Lari Hotari Assignee: Lari Hotari
Resolution: Fixed Votes: 0

Attachments: File hs_err_pid16435.log    

 Description   

Continuous build sporadically crashes the JVM of the Gradle Scala Zinc compiler daemon.
The reason seems to be that continuous build is modifying jar files that are kept open and mmapped by the compiler daemon JVM process.

Relevant parts of the crash log file:

Stack: [0x00007ff2ff5d0000,0x00007ff2ff6d1000],  sp=0x00007ff2ff6cab50,  free space=1002k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libzip.so+0x116d2]  newEntry+0x62
C  [libzip.so+0x11e00]  ZIP_GetEntry+0xd0
C  [libzip.so+0x3c9d]  Java_java_util_zip_ZipFile_getEntry+0xad
J 218  java.util.zip.ZipFile.getEntry(J[BZ)J (0 bytes) @ 0x00007ff30917780e [0x00007ff309177740+0xce]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 218  java.util.zip.ZipFile.getEntry(J[BZ)J (0 bytes) @ 0x00007ff309177798 [0x00007ff309177740+0x58]
J 9830 C2 java.util.zip.ZipFile.getEntry(Ljava/lang/String;)Ljava/util/zip/ZipEntry; (86 bytes) @ 0x00007ff30ab415b8 [0x00007ff30ab41280+0x338]
J 735 C2 sun.misc.URLClassPath.getResource(Ljava/lang/String;Z)Lsun/misc/Resource; (74 bytes) @ 0x00007ff3092e6b64 [0x00007ff3092e6aa0+0xc4]
J 9829 C1 java.net.URLClassLoader$1.run()Ljava/lang/Class; (73 bytes) @ 0x00007ff30ab1dd3c [0x00007ff30ab1dc80+0xbc]
J 6689 C1 java.net.URLClassLoader$1.run()Ljava/lang/Object; (5 bytes) @ 0x00007ff309784f24 [0x00007ff309784ec0+0x64]
v  ~StubRoutines::call_stub
J 372  java.security.AccessController.doPrivileged(Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object; (0 bytes) @ 0x00007ff3091d6ea3 [0x00007ff3091d6e40+0x63]
J 10154 C1 java.net.URLClassLoader.findClass(Ljava/lang/String;)Ljava/lang/Class; (29 bytes) @ 0x00007ff30982a924 [0x00007ff30982a840+0xe4]
J 10024 C1 java.lang.ClassLoader.loadClass(Ljava/lang/String;Z)Ljava/lang/Class; (122 bytes) @ 0x00007ff30964b074 [0x00007ff30964ad20+0x354]
J 10004 C2 java.lang.ClassLoader.loadClass(Ljava/lang/String;)Ljava/lang/Class; (7 bytes) @ 0x00007ff309396a00 [0x00007ff3093969c0+0x40]
v  ~StubRoutines::call_stub
j  xsbt.Dependency.xsbt$Dependency$$extractDependenciesByInheritance(Lscala/tools/nsc/CompilationUnits$CompilationUnit;)Lscala/collection/immutable/Set;+0
j  xsbt.Dependency$DependencyPhase$$anonfun$run$2.apply(Lscala/tools/nsc/CompilationUnits$CompilationUnit;)V+67
j  xsbt.Dependency$DependencyPhase$$anonfun$run$2.apply(Ljava/lang/Object;)Ljava/lang/Object;+5

Zip file handling in Java uses mmapped files by default. Modifying mmapped files causes problems.

There is a system property to disable the usage of mmap in zip file handling. This property was introduced in Java 6u21:

Changes in 6u21-rev-b09

Disabling mmap Usage (on Solaris or Linux)
This release includes a new system property, sun.zip.disableMemoryMapping, which allows the user to disable the mmap usage in Sun's java.util.zip.Zipfile implementation (on Solaris and Linux platforms). Solaris or Linux applications that use java.util.zip.ZipFile may experience a SIGBUS VM crash if the application accidentally overwrites any zip or jar files that are still being used by the same Java runtime. Although this is a programming error of the offending application, this system property provides a solution to avoid the VM crash. With the property set to true (-Dsun.zip.disableMemoryMapping=true, or simply -Dsun.zip.disableMemoryMapping) the Sun JDK/JRE runtime disables the mmap usage and the VM crash that might otherwise occur by overwriting the jar or zip file can be avoided.

In most cases the zip file is kept open by the URL caching of the JVM. By disabling URL caching the zip files get closed after use and that prevents crashes in some cases. This is the preferred solution to fixing crashes in Java zip file handling.

// code for disabling URL caching
new URL("jar:file://valid_jar_url_syntax.jar!/").openConnection().setDefaultUseCaches(false);


 Comments   
Comment by Lari Hotari [ 09/Dec/15 ]

More information about crashes when updating Jar files in https://bugs.openjdk.java.net/browse/JDK-4425695 .

Generated at Wed Jun 30 12:47:01 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.