Bug 38526

Summary: RuntimeException: Couldn't instantiate the class for type with id 0
Product: POI Reporter: Trejkaz (pen name) <trejkaz>
Component: HSLFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: Other   
OS: other   
Attachments: PPT file exhibiting the problem.

Description Trejkaz (pen name) 2006-02-06 06:03:50 UTC
On latest version in SVN, constructing an HSLFSlideShow on a certain slide show,
I get the following error:

java.lang.RuntimeException: Couldn't instantiate the class for type with id 0 on
class class org.apache.poi.hslf.record.UnknownRecordPlaceholder :
java.lang.reflect.InvocationTargetException
Cause was : java.lang.ArrayIndexOutOfBoundsException
        at org.apache.poi.hslf.record.Record.createRecordForType(Record.java:158)
        at org.apache.poi.hslf.record.Record.findChildRecords(Record.java:109)
        at org.apache.poi.hslf.HSLFSlideShow.readFIB(HSLFSlideShow.java:174)
        at org.apache.poi.hslf.HSLFSlideShow.<init>(HSLFSlideShow.java:103)
Comment 1 Trejkaz (pen name) 2006-02-06 06:05:14 UTC
Created attachment 17600 [details]
PPT file exhibiting the problem.

Here's the file in question.  It opens in Office and OpenOffice, looks to be
pretty innocent but breaks in HSLF for some reason.
Comment 2 Nick Burch 2006-02-06 13:59:22 UTC
Following the normal slide records, that PPT file than has 63 records of type 0.
The first 62 are of zero length (so just the 8 byte record header), and the
final one is 251658240 bytes big!

I'm happy to code up something to ignore the empty records of type 0. I'm less
happy about the whacking great record

How did you go about creating this file, and is there anything special about it?
Comment 3 Nick Burch 2006-02-06 14:04:30 UTC
On closer inspection, that last record claims to be ~250mb in size, as part of a
62kb file! Something is corrupt somewhere in that PPT file, but I'll see if I
can come up with a sensible way to handle documents with corruption like that.
Comment 4 Nick Burch 2006-02-06 14:14:02 UTC
OK, SVN now has a fix. If a record claims to be larger than the available data,
it will be silently ignored. I can now process that file fine with HSLF.

Note - if you open a corrupt file like this, and write it back out again, it
will be changed! (The corrupt record will be discarded)
Comment 5 Trejkaz (pen name) 2006-02-07 00:19:44 UTC
Ah, so it was corrupt... I was wondering about that, because even OpenOffice
opened it silently.  I actually got the PPT file out of a large set of PPT files
created by other people, so it's impossible to know exactly which versions they
used and what sort of shenanigans went on. :-)
Comment 6 Trejkaz (pen name) 2006-02-07 00:58:26 UTC
Darn.  This does prevent the error being thrown, but now getTextRuns() returns
no text.  OpenOffice can show the text, so there must be something that can be
done to retrieve it.

Feel free to re-close this if it looks like it's completely impossible to get
out because of that corrupt record.
Comment 7 Yegor Kozlov 2007-05-29 01:42:15 UTC
Fixed, though it wasn't trivial.
In the attached file root-level records were not continuous and some of them
were skipped with the "Skipping record of type 0 at position ..." message in
System.err. 
As the result, the wrong Slide record was selected with no text runs.
Should work fine now.

Yegor