6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
Alan Bateman
Alan.Bateman at oracle.com
Mon Jul 26 11:26:59 PDT 2010
Rémi Forax wrote:
> Hi Alan,
> in MappedBytBuffer:
> pagePosition() should return a long, this will avoid most of the casts.
> mappedPageCount() should take the value of mappedLength() as parameter
> and mappedAddress() and mappedLength() should take the value of
> pagePosition() as parameter to avoid to calculate pagePosition() more
> than once.
Thanks Rémi, these are good idea (these operations are rarely used but
it was a stupid of me to re-calculate the offset more than once).
>
> In load, you store the pageSize() in ps but doesn't use it after,
> I suppose that your intention was to use it in the loop.
> for (int i=0; i<count; i++) {
> unsafe.getByte(a);
> a += ps;
> }
> otherwise, it looks fine.
You have 20/20 vision - the intention was to use ps in the loop.
I've put an updated webrev here:
http://cr.openjdk.java.net/~alanb/6934977/webrev.2/
-Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20100726/ea8bd4ed/attachment.html
More information about the nio-dev
mailing list