JDK-7114611 : (fs) DirectoryStream fails with SIGBUS on some embedded platforms, dirent alignment
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 7u2
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-11-22
  • Updated: 2014-10-13
  • Resolved: 2012-05-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u4Fixed 8 b27Fixed
Related Reports
Relates :  
Description
Several JCK tests crash with SIGBUS in readdir64_r. The crash only happens when /proc/cpu/alignment is set not to ignore alignment errors (i.e. echo 5 > /proc/cpu/alignment). See Comments for more details.

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGBUS (0x7) at pc=0x400fd7cc, pid=3863, tid=1081996400
#
# JRE version: 7.0_02-b12
# Java VM: Java HotSpot(TM) Client VM (22.0-b09 mixed mode, sharing linux-arm )
# Problematic frame:
# C  [libc.so.6+0x907cc]  readdir64_r+0xe0

Stack: [0x40790000,0x407e0000],  sp=0x407dd2d8,  free space=308k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libc.so.6+0x907cc]  readdir64_r+0xe0

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  sun.nio.fs.UnixNativeDispatcher.readdir(J)[B+0
j  sun.nio.fs.UnixDirectoryStream$UnixDirectoryIterator.readNextEntry()Ljava/nio/file/Path;+52
j  sun.nio.fs.UnixDirectoryStream$UnixDirectoryIterator.hasNext()Z+16
j  javasoft.sqe.tests.api.java.nio.file.Files.CpMvDelTests$2.runTest()Ljavasoft/sqe/javatest/Status;+212
j  javasoft.sqe.tests.api.java.nio.Nio2TestCase$Single.runTestSafely()Ljavasoft/sqe/javatest/Status;+1
j  javasoft.sqe.tests.api.java.nio.Nio2TestCase$Single.runTestWithPerms(Z[Ljava/security/Permission;)Ljavasoft/sqe/javatest/Status;+196
j  javasoft.sqe.tests.api.java.nio.Nio2TestCase$Single.runTestWithAllPermsGranted()Ljavasoft/sqe/javatest/Status;+6
j  javasoft.sqe.tests.api.java.nio.file.Files.CpMvDelTests.copy_DirDefault()Ljavasoft/sqe/javatest/Status;+101
v  ~StubRoutines::call_stub
j  sun.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0
j  sun.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+87
j  sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+57
j  javasoft.sqe.javatest.lib.MultiTest.invokeTestCase(Ljava/lang/reflect/Method;)Ljavasoft/sqe/javatest/Status;+8
j  javasoft.sqe.javatest.lib.MultiTest.run([Ljava/lang/String;Ljava/io/PrintWriter;Ljava/io/PrintWriter;)Ljavasoft/sqe/javatest/Status;+152
j  javasoft.sqe.javatest.lib.MultiTest.run([Ljava/lang/String;Ljava/io/PrintStream;Ljava/io/PrintStream;)Ljavasoft/sqe/javatest/Status;+40
j  javasoft.sqe.tests.api.java.nio.file.Files.CpMvDelTests.main([Ljava/lang/String;)V+16
v  ~StubRoutines::call_stub

Comments
EVALUATION http://hg.openjdk.java.net/jdk8/tl/jdk/rev/184b9cb4f13a
09-02-2012

EVALUATION Correction, "entry" may need double-word alignment, which is what "ptr" points to.
29-11-2011

SUGGESTED FIX struct dirent64* result; struct { struct dirent64 buf; char name_extra[PATH_MAX + 1 - sizeof result->d_name]; } entry; struct dirent64* ptr = &entry.buf;
22-11-2011

EVALUATION JNIEXPORT jbyteArray JNICALL Java_sun_nio_fs_UnixNativeDispatcher_readdir(JNIEnv* env, jclass this, jlong val ue) { char entry[sizeof(struct dirent64) + PATH_MAX + 1]; struct dirent64* ptr = (struct dirent64*)&entry; In the above code, ptr may need double-word alignment, but it won't get that from a char[].
22-11-2011