6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated

Rémi Forax forax at univ-mlv.fr
Tue Jul 27 08:11:49 PDT 2010


Le 26/07/2010 20:26, Alan Bateman a écrit :
> 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.

Ok, looks fine.

Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20100727/cd8c2264/attachment.html 


More information about the nio-dev mailing list