Bug 56465

Summary: Error message: "does your POIFS have circular or duplicate block references"
Product: POI Reporter: peter.fetzer
Component: POIFSAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: 3.9-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: zip file containing 3 sample word documents

Description peter.fetzer 2014-04-28 07:03:58 UTC
Created attachment 31565 [details]
zip file containing 3 sample word documents

We processed some client documents where this exception was raised.  I can recreate the exception if I take a 'good' Word document, and zero out the last 100 or so bytes, samples attached.  I'm guessing the problem documents had an error when writing to disk.  The zeroed bytes 

Microsoft Word opens these documents okay, and saving them in Word will fix them.

Attached are
1. original document
2. corrupted version, I've zeroed out a bunch of bytes at the end, and slightly reduced the file size (matching the original client documents)
3. fixed version, after opened and saved in Word 2013

The full exception is

java.io.IOException: block[ 0 ] already removed - does your POIFS have circular or duplicate block references? 
        at org.apache.poi.poifs.storage.BlockListImpl.remove(BlockListImpl.java:89) 
        at org.apache.poi.poifs.storage.SmallDocumentBlockList.remove(SmallDocumentBlockList.java:30) 
        at org.apache.poi.poifs.storage.BlockAllocationTableReader.fetchBlocks(BlockAllocationTableReader.java:221) 
        at org.apache.poi.poifs.storage.BlockListImpl.fetchBlocks(BlockListImpl.java:123) 
        at org.apache.poi.poifs.storage.SmallDocumentBlockList.fetchBlocks(SmallDocumentBlockList.java:30) 
        at org.apache.poi.poifs.filesystem.POIFSFileSystem.processProperties(POIFSFileSystem.java:535) 
        at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:164)
Comment 1 Nick Burch 2014-04-28 07:29:34 UTC
Use NPOIFSFileSystem instead - it has a lower memory footprint AND fixes some deep seated issues POIFSFileSystem had with certain files where it got confused about circular references that didn't actually exist