Bug 41246 - ArrayIndexOutOfBoundsException
Summary: ArrayIndexOutOfBoundsException
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: 3.8-dev
Hardware: PC All
: P5 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-27 01:02 UTC by Eitan
Modified: 2013-12-27 23:57 UTC (History)
1 user (show)



Attachments
MS powerpoint file (269.00 KB, application/vnd.ms-powerpoint)
2006-12-27 01:03 UTC, Eitan
Details
Throws ArrayIndexOutOfBoundsException in SlideShow.buildSlidesAndNotes() (142.50 KB, application/vnd.ms-powerpoint)
2011-09-29 14:18 UTC, pqueixalos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eitan 2006-12-27 01:02:14 UTC
Trying to instantiate a SlideShow with the attached file throws the following
exception:

java.lang.ArrayIndexOutOfBoundsException - 39
      at org.apache.poi.util.LittleEndian.getInt(LittleEndian.java:140)
      at
org.apache.poi.hslf.record.StyleTextPropAtom.setParentTextSize(StyleTextPropAtom.java:259)
      at org.apache.poi.hslf.model.TextRun.<init>(TextRun.java:95)
      at org.apache.poi.hslf.model.TextRun.<init>(TextRun.java:72)
      at org.apache.poi.hslf.model.Sheet.findTextRuns(Sheet.java:136)
      at org.apache.poi.hslf.model.Slide.<init>(Slide.java:82)
      at
org.apache.poi.hslf.usermodel.SlideShow.buildSlidesAndNotes(SlideShow.java:444)
      at org.apache.poi.hslf.usermodel.SlideShow.<init>(SlideShow.java:122)
Comment 1 Eitan 2006-12-27 01:03:42 UTC
Created attachment 19307 [details]
MS powerpoint file

This attached MS-PowerPoint presentation caused the exception
Comment 2 Yegor Kozlov 2007-01-10 06:07:11 UTC
The bug has the same origin as Bug 40143. 

Regards,
Yegor
Comment 3 Nick Burch 2007-01-16 07:54:01 UTC
I think this problem has now been fixed, thanks to Yegor's new understanding
of the ordering of TextProps in StyleTextPropAtom

I can open your test powerpoint document without any exceptions, so I'm
hoping this is now closed. If you still get problems, can you re-open with a new
problem file?
Comment 4 pqueixalos 2011-09-29 14:14:39 UTC
Got this Exception (through Tika) (POI r1175705) :

java.lang.ArrayIndexOutOfBoundsException: 16
  at org.apache.poi.hslf.usermodel.SlideShow.buildSlidesAndNotes(SlideShow.java:405)
  at org.apache.poi.hslf.usermodel.SlideShow.<init>(SlideShow.java:109)
Comment 5 Nick Burch 2011-09-29 14:16:57 UTC
(In reply to comment #4)
> Got this Exception (through Tika) (POI r1175705) :
> 
> java.lang.ArrayIndexOutOfBoundsException: 16
>   at
> org.apache.poi.hslf.usermodel.SlideShow.buildSlidesAndNotes(SlideShow.java:405)
>   at org.apache.poi.hslf.usermodel.SlideShow.<init>(SlideShow.java:109)

Any chance you could post a file that shows the problem?
Comment 6 pqueixalos 2011-09-29 14:18:14 UTC
Created attachment 27635 [details]
Throws ArrayIndexOutOfBoundsException in SlideShow.buildSlidesAndNotes()
Comment 7 Andrew 2011-11-28 07:53:59 UTC
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002

Caused by: java.lang.ArrayIndexOutOfBoundsException: 36
	at org.apache.poi.util.LittleEndian.getInt(LittleEndian.java:95)
	at org.apache.poi.hslf.record.StyleTextPropAtom.setParentTextSize(StyleTextPropAtom.java:319)
	at org.apache.poi.hslf.model.TextRun.<init>(TextRun.java:100)
	at org.apache.poi.hslf.model.TextRun.<init>(TextRun.java:77)
	at org.apache.poi.hslf.model.Sheet.findTextRuns(Sheet.java:175)
	at org.apache.poi.hslf.model.Sheet.findTextRuns(Sheet.java:132)
	at org.apache.poi.hslf.model.Slide.<init>(Slide.java:70)
	at org.apache.poi.hslf.usermodel.SlideShow.buildSlidesAndNotes(SlideShow.java:411)
	at org.apache.poi.hslf.usermodel.SlideShow.<init>(SlideShow.java:109)
	at com.open.common.ppt.ReportUtility.writePPTNew(ReportUtility.java:1689)
	at com.auchan.crs.service.report.templatemgt.ReportAjaxService.ajaxCreateReportNew(ReportAjaxService.java:716)
	at com.auchan.crs.view.action.report.templatemgt.ReportAjaxAction.ajaxCreateReportNew(ReportAjaxAction.java:789)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.open.framework.view.DispatchAction.dispatchMethod(DispatchAction.java:264)
	... 26 more
Comment 8 Andrew 2011-11-28 07:56:26 UTC
I can't believe, this bug can living 4 years.
:)

POI HSLF 3.8 dev
Comment 9 MaryAubaun 2012-04-09 23:03:04 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > Got this Exception (through Tika) (POI r1175705) :
> > 
> > java.lang.ArrayIndexOutOfBoundsException: 16
> >   at
> > org.apache.poi.hslf.usermodel.SlideShow.buildSlidesAndNotes(SlideShow.java:405)
> >   at org.apache.poi.hslf.usermodel.SlideShow.<init>(SlideShow.java:109)
> 
> Any chance you could post a file that shows the problem?

I also have a file that gives similar errors in POI 3.8.  I can send it, but not onto a public forum, and I can't clean it up because if I make any changes to it, it no longer gives the error!

Is there a way to send it to just a few people, and not have it be available to everyone?

java.lang.ArrayIndexOutOfBoundsException: 60
	at org.apache.poi.util.LittleEndian.getInt(LittleEndian.java:163)
	at org.apache.poi.hslf.record.StyleTextPropAtom.setParentTextSize(StyleTextPropAtom.java:319)
	at org.apache.poi.hslf.model.TextRun.<init>(TextRun.java:100)
	at org.apache.poi.hslf.model.TextRun.<init>(TextRun.java:77)
	at org.apache.poi.hslf.model.Sheet.findTextRuns(Sheet.java:170)
	at org.apache.poi.hslf.model.Sheet.findTextRuns(Sheet.java:131)
	at org.apache.poi.hslf.model.Slide.<init>(Slide.java:70)
	at org.apache.poi.hslf.usermodel.SlideShow.buildSlidesAndNotes(SlideShow.java:411)
	at org.apache.poi.hslf.usermodel.SlideShow.<init>(SlideShow.java:109)
Comment 10 Nick Burch 2012-04-10 00:06:50 UTC
Do the problem files pass the Binary File Format Validator? <http://poi.apache.org/faq.html#faq-N10109> And do you know how the files were generated?
Comment 11 MaryAubaun 2012-04-10 14:27:31 UTC
(In reply to comment #10)
> Do the problem files pass the Binary File Format Validator?
> <http://poi.apache.org/faq.html#faq-N10109> And do you know how the files were
> generated?

Thanks for the validator link, the file DOES pass the validator.  I can't tell how it was generated and suspect from an old version of PowerPoint.
Comment 12 Nick Burch 2012-04-10 15:13:05 UTC
Any chance that you could use the tools in org.apache.poi.hslf.dev to produce a hex dump of your StyleTextPropAtoms? Ideally just the problematic one (you might need to fetch all the records, and iterate through setting the text size until you find the one that breaks)

HSLF seems to have an idea on the number of parts that make up the style, and it's running off the end part way through reading a style, so we need to get the hex dump to work out why
Comment 13 MaryAubaun 2012-04-10 22:43:58 UTC
(In reply to comment #12)
> Any chance that you could use the tools in org.apache.poi.hslf.dev to produce a
> hex dump of your StyleTextPropAtoms? Ideally just the problematic one (you
> might need to fetch all the records, and iterate through setting the text size
> until you find the one that breaks)
> 
> HSLF seems to have an idea on the number of parts that make up the style, and
> it's running off the end part way through reading a style, so we need to get
> the hex dump to work out why

I may be able to figure that out, though I would need more help.  And I suspect it would then involve a lot of back and forth after that.

Nick, can I send you the file instead?
Comment 14 Nick Burch 2012-04-10 23:32:56 UTC
(In reply to comment #13)
> I may be able to figure that out, though I would need more help.  And I suspect
> it would then involve a lot of back and forth after that.
> 
> Nick, can I send you the file instead?

I'm a bit busy at work at the moment (paying customers and all that!), so I won't have a chance to look at it soon, sorry. Once of the other POI developers may do though. Another option is just to run the problem code in a debugger, and use that to grab out the header and rawContents of the StyleTextPropAtom that blows up
Comment 15 MaryAubaun 2012-04-12 15:16:13 UTC
(In reply to comment #12)
> I'm a bit busy at work at the moment (paying customers and all that!), so I
> won't have a chance to look at it soon, sorry. Once of the other POI developers
> may do though.

Thanks, Nick.  I will see if any other developer comments, and will send the file to them.  In the meantime, I will run it through debug and see what I can find.
Comment 16 Andreas Beeker 2013-12-27 23:57:15 UTC
fixed with SVN ver r1553760.

The problem was/is that there are note references in the SlideListWithText(Notes) with no corresponding note record, i.e. the references point beyond the last record. The fix simply puts null records in the notesRecords list.
So user code which uses such malformed files have to check for null notes -
it might be nicer to generate default note entries, but as this seems to be rare legacy problem, I've skipped the implementation for that ...

Apart of that rewriting the files works.