Bug 48894 - gij fails with bus error when executing ant 1.8
Summary: gij fails with bus error when executing ant 1.8
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.8.0
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: 1.8.1
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-11 21:37 UTC by Torsten Werner
Modified: 2010-03-12 09:25 UTC (History)
0 users



Attachments
[PATCH] Fix bus overflow (1.04 KB, patch)
2010-03-11 22:19 UTC, Ludovic Claude
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Torsten Werner 2010-03-11 21:37:15 UTC
Please have a look at <http://svn.debian.org/viewsvn/pkg-java/trunk/ant/debian/patches/>. There is a patch 0010-fix-bus-error-in-gij.patch that fixes this problem. Please consider applying it.

When you are at it: may you check the other patches, too? Maybe you can apply parts of it?
Comment 1 Ludovic Claude 2010-03-11 22:19:43 UTC
Created attachment 25117 [details]
[PATCH] Fix bus overflow
Comment 2 J.M. (Martijn) Kruithof 2010-03-12 08:45:55 UTC
The Bus overflow error is in gij, not in ant. Javadoc of FileChannel explicitly states:

Fewer than the requested number of bytes are transferred if this channel's file contains fewer than count bytes starting at the given position, or if the target channel is non-blocking and it has fewer than count bytes free in its output buffer.

And also:
This method is potentially much more efficient than a simple loop that reads from this channel and writes to the target channel. Many operating systems can transfer bytes directly from the filesystem cache to the target channel without actually copying them. 

Applying this fix won't fix the bus overflow in gij, and may increase the requested copy buffer size to the entire file size. Again even if we did this, and an in-memory buffer is necessary, the actual buffer size used would be up to the FileChannel, and be the resposibility of the FileChannel.

Will apply this patch, but please put the bus error bug in debian back where it belongs (gij).

commited in:
http://svn.apache.org/viewvc?rev=922179&view=rev
Comment 3 Torsten Werner 2010-03-12 08:51:26 UTC
The bug in gij is reported here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=571532 and it contains some extra information.
Comment 4 J.M. (Martijn) Kruithof 2010-03-12 09:11:21 UTC
also there the "blame" is put on ant
ant tries to mmap stdin (not true, ant does not mmap at all, the underlying implementation of FileChannel in the virtual machine does (strange though a file channel on stdin?) (or in case the code is compiled the corresponding  )

From the bug report:
If ant mmap's a file that has only 1701 bytes, on an architecture with
page size of 4906, then any access beyond the first page will cause a
SIGBUS.

ant does not mmap, the native code behind the FileChannel implementation does.

The problem is that FileUtils.BUF_SIZE (8192)
is currently bigger than page size (4096)...

the buf size in ant is larger than the page size, again responsibility of the implementation of the FileChannel, not the responsibility of ant.

Apparently there is a bug in gij or its libraries, ant may trigger that bug, but please issue the bug to gij again.

According to the FileChannel documentation it is explicitly allowed to provide a larger count than the (remaining) size of the originating file. If gij and its libraries do not follow that contract it is a bug in gij, not in ant.