JDK 9 RFR of 8168628: (ch) JVM Crash in : ~StubRoutines::jshort_disjoint_arraycopy

Langer, Christoph christoph.langer at sap.com
Fri Dec 2 08:03:50 UTC 2016


Hi Brian,

this looks good to me.

However, I don't fully understand: Is this handling 2 different issues? The one is the missing thread synchronization in the map() method and the other is the allocation that does not happen upon extension? I'm trying to understand why only linux is affected...

Small formatting nit:
src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c
203     if (fstat64(fd, &fbuf) == 0 && size > fbuf.st_blocks*512) {
You could place spaces around '*'.

Best regards
Christoph

> -----Original Message-----
> From: nio-dev [mailto:nio-dev-bounces at openjdk.java.net] On Behalf Of Brian
> Burkhalter
> Sent: Freitag, 2. Dezember 2016 03:13
> To: nio-dev <nio-dev at openjdk.java.net>
> Subject: JDK 9 RFR of 8168628: (ch) JVM Crash in :
> ~StubRoutines::jshort_disjoint_arraycopy
> 
> Please review at your convenience:
> 
> Issue:	https://bugs.openjdk.java.net/browse/JDK-8168628
> Patch:	http://cr.openjdk.java.net/~bpb/8168628/webrev.00/
> 
> The FileChannel.map() method extends the size of the file being mapped when
> it is not already sufficiently large. On Unix, file size extension is implemented
> via the ftruncate() function. On Linux, this function does not actually allocate
> any blocks for the file when the new size is larger than the existing size. This
> may cause problems when the file is memory-mapped. This might occur
> proximately because map() may be invoked from multiple, different threads
> wherein one thread reduces the size of a file previously mapped at a larger size
> by another thread. The eventual result is a SIGBUS.
> 
> This patch addresses the problem by using fallocate() on Linux when the
> requested size exceeds the allocated size, and by synchronizing on positionLock
> in the section in FileChannelImpl.map() where the file is extended. Note that
> the same crash is observed on OS X without the addition of this synchronization.
> 
> Thanks,
> 
> Brian
> 
> [1] https://linux.die.net/man/2/ftruncate


More information about the nio-dev mailing list