Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] DfsBlockCache: ArrayIndexOutOfBoundsException and java.util.zip.DataFormatException

The block size should be a power of 2, attempting to set it to a
non-power of 2 should either fail hard, or round down to the closest
power of 2.

On Fri, Nov 4, 2016 at 3:05 AM, Philipp Marx <smigfu@xxxxxxxxxxxxxx> wrote:
> Hi,
>
> if you configure the DfsBlockCache with a blockSize which is not a power of
> 2 there is a chance of running into ArrayIndexOutOfBoundsException or
> java.util.zip.DataFormatException (see StackTraces at [1] and [2] for a
> blockSize of 500.000). This is related to the DfsBlockCache#blockSizeShift
> parameter.
>
> I would like to provide a fix for that but the question is how would this be
> fixed best?
>
> 1. Just document it on the DfsBlockCache#setBlockSize
> 2. additionally to 1. throw an exception in case the value is not a power of
> 2
> 3. additionally to 1. automatically adjust the value to the previous/next
> best fit to the given value and log a warning. Though with high values the
> previous/next best fit might be far of the original value.
> 4. Make sure to cap the upper bound properly in the methods down in the
> StackTrace.
>
> Cheers,
> Philipp
>
> [1]
> Caused by: org.eclipse.jgit.errors.CorruptObjectException: Object at 499,510
> in 64913f3f-af3d-282b-0394-1e56e80a43af.pack has bad zlib stream
> at org.eclipse.jgit.internal.storage.dfs.DfsPackFile.l ackFile.java:984)
> at
> org.eclipse.jgit.internal.storage.dfs.DfsPackFile.get(DfsPackFile.java:411)
> at
> org.eclipse.jgit.internal.storage.dfs.DfsReader.openImpl(DfsReader.java:263)
> at org.eclipse.jgit.internal.storage.dfs.DfsReader.open(DfsReader.java:232)
> at org.eclipse.jgit.lib.ObjectReader.open(ObjectReader.java:227)
> at org.eclipse.jgit.revwalk.RevWalk.parseAny(RevWalk.java:859)
> at org.eclipse.jgit.revwalk.RevWalk.parseCommit(RevWalk.java:772)
> ... 109 more
> Caused by: java.util.zip.DataFormatException: 0 bytes to inflate: at
> pos=499712; block.start=0; ptr=499712; block.length=499712
> at org.eclipse.jgit.internal.storage.dfs.DfsBlock.setInput(DfsBlock.java:95)
> at
> org.eclipse.jgit.internal.storage.dfs.DfsReader.inflate(DfsReader.java:671)
> at
> org.eclipse.jgit.internal.storage.dfs.DfsPackFile.decompress(DfsPackFile.java:460)
> at
> org.eclipse.jgit.internal.storage.dfs.DfsPackFile.load(DfsPackFile.java:884)
>
>
> [2]
> java.lang.ArrayIndexOutOfBoundsException
> at org.eclipse.jgit.internal.storage.dfs.DfsBlock.copy(DfsBlock.java:87)
> at org.eclipse.jgit.internal.storage.dfs.DfsBlock.copy(DfsBlock.java:82)
> at org.eclipse.jgit.internal.storage.dfs.DfsReader.copy(DfsReader.java:628)
> at
> org.eclipse.jgit.internal.storage.dfs.DfsPackFile.readFully(DfsPackFile.java:752)
> at
> org.eclipse.jgit.internal.storage.dfs.DfsPackFile.load(DfsPackFile.java:860)
> at
> org.eclipse.jgit.internal.storage.dfs.DfsPackFile.get(DfsPackFile.java:411)
> at
> org.eclipse.jgit.internal.storage.dfs.DfsReader.openImpl(DfsReader.java:263)
> at org.eclipse.jgit.internal.storage.dfs.DfsReader.open(DfsReader.java:232)
> at org.eclipse.jgit.lib.ObjectReader.open(ObjectReader.java:227)
> at org.eclipse.jgit.revwalk.RevWalk.parseAny(RevWalk.java:859)
> at org.eclipse.jgit.revwalk.RevWalk.parseCommit(RevWalk.java:772)
>
>
>
> _______________________________________________
> jgit-dev mailing list
> jgit-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/jgit-dev


Back to the top