-
Bug
-
Resolution: Fixed
-
P4
-
20, 21
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8317805 | 21.0.2 | Brian Burkhalter | P4 | Resolved | Fixed | b03 |
ADDITIONAL SYSTEM INFORMATION :
OS Fedora 34
Java 20.0.1+9 (temurin build) (but issue seems to be relevant for 20.0.2 also)
A DESCRIPTION OF THE PROBLEM :
The implementation of FileChannel.size should use ioctl(BLKGETSIZE64) for block special devices.
For java 20 it's never called (checked with strace)
Looks like a regression from https://github.com/openjdk/jdk20/commit/48cc15602b62e81bb179ca9570a1e7d8bbf4d6df
Java 19 (https://github.com/openjdk/jdk19/blob/master/src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c) imports `<linux/fs.h>` which includes definition of `BLKGETSIZE64`
Java 20 (https://github.com/openjdk/jdk20/blob/master/src/java.base/unix/native/libnio/ch/UnixFileDispatcherImpl.c) doesn't import, so BLKGETSIZE64 is never defined and ioctl is never called
REGRESSION : Last worked in version 20
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- create block device with non-empty size
- check `blockdev --getsize64 /dev/sample.block` has size not 0
- run `java SizeError.java`
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Prints size
ACTUAL -
Prints zero and "WRONG"
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
public class SizeError {
public static void main(String[] args) throws IOException {
var ch = FileChannel.open(Path.of("/dev/sample.block"));
var size = ch.size();
System.out.println(size);
if (size == 0L) System.out.println("WRONG");
}
}
---------- END SOURCE ----------
OS Fedora 34
Java 20.0.1+9 (temurin build) (but issue seems to be relevant for 20.0.2 also)
A DESCRIPTION OF THE PROBLEM :
The implementation of FileChannel.size should use ioctl(BLKGETSIZE64) for block special devices.
For java 20 it's never called (checked with strace)
Looks like a regression from https://github.com/openjdk/jdk20/commit/48cc15602b62e81bb179ca9570a1e7d8bbf4d6df
Java 19 (https://github.com/openjdk/jdk19/blob/master/src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c) imports `<linux/fs.h>` which includes definition of `BLKGETSIZE64`
Java 20 (https://github.com/openjdk/jdk20/blob/master/src/java.base/unix/native/libnio/ch/UnixFileDispatcherImpl.c) doesn't import, so BLKGETSIZE64 is never defined and ioctl is never called
REGRESSION : Last worked in version 20
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- create block device with non-empty size
- check `blockdev --getsize64 /dev/sample.block` has size not 0
- run `java SizeError.java`
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Prints size
ACTUAL -
Prints zero and "WRONG"
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
public class SizeError {
public static void main(String[] args) throws IOException {
var ch = FileChannel.open(Path.of("/dev/sample.block"));
var size = ch.size();
System.out.println(size);
if (size == 0L) System.out.println("WRONG");
}
}
---------- END SOURCE ----------
- backported by
-
JDK-8317805 (fc) FileChannel.size returns 0 on block special files
- Resolved
- relates to
-
JDK-8293331 Refactor FileDispatcherImpl into operating system-specific components
- Resolved
- links to
-
Commit openjdk/jdk21u/edc15aa6
-
Commit openjdk/jdk/4ba81f63
-
Review openjdk/jdk21u/228
-
Review openjdk/jdk/15092
(1 links to)