[forwarded from http://bugs.debian.org/571532] running ant 1.8 on gij (4.4/4.5) terminates with a BUS error (on hppa-linux); that the only debian port still using gij as default VM, but should be present on other archs as well. bug reporter writes: The problem is triggered by this line, for any small file, which seems to me allowed by java specification srcChannel.transferTo(0, FileUtils.BUF_SIZE,destChannel); http://java.sun.com/j2se/1.4.2/docs/api/java/nio/channels/FileChannel.html: An attempt is made to read up to count bytes from the source channel and write them to this channel's file starting at the given position. An invocation of this method may or may not transfer all of the requested bytes; whether or not it does so depends upon the natures and states of the channels. Fewer than the requested number of bytes will be transferred if the source channel has fewer than count bytes remaining, or if the source channel is non-blocking and has fewer than count bytes immediately available in its input buffer. It is implemented in libjava/gnu/java/nio/channels/FileChannelImpl.java via smallTransferTo() via map() via mapImpl(). The specification of map() explicitely states: Many of the details of memory-mapped files are inherently dependent upon the underlying operating system and are therefore unspecified. The behavior of this method when the requested region is not completely contained within this channel's file is unspecified. The transferTo(0, 8192, ...) is translated into mmap() of 8192 bytes from file of size 1701 on architecture with pagesize 4096. This system call succeeds, the later acces to 2nd page fails. Moreover, it looks like transferTo(0, 4096, ...) would write 4096 bytes to destination file from file with size 1701. The implementaion of smallTransferTo() should be fixed. It can be shown by this snippet: ----------------------------------------- import java.io.FileInputStream; import java.io.FileOutputStream; import java.nio.channels.FileChannel; public class Tra { public static void main(String[] args) throws Exception { if (args.length != 2) { System.out.println("arguments: sourcefile destfile"); System.exit(1); } FileChannel in = new FileInputStream(args[0]).getChannel(), out = new FileOutputStream(args[1]).getChannel(); in.transferTo(0, 4096, out); } } ---------------------------------------------