[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#571532: gij: Bus error when executing ant



Hi.

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.

IMHO, the implementaion of smallTransferTo() should be fixed.

Petr



Reply to: