I think the second part of this conditional (otp.getDeltaBase() != null) is what causes the corruption. When there is a delta chain cycle (A->B->A) neither A nor B gets through this condition, so neither runs writeObjectAndDeltaChildren(), and neither appears in the pack output stream. This means the pack doesn't contain the number of objects declared in its header, causing IndexPack to abort with an early EOF error, and the index stores a bunch of objects with offset=0. Trying to read those back always fails, because the first byte of the pack ('P') appears to have object type code = 5, which is a currently invalid code.