Bug 94756

Summary: poppler displays blank pages
Product: poppler Reporter: octoploid <octoploid>
Component: generalAssignee: poppler-bugs <poppler-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: bjorn.lie, octoploid
Version: unspecified   
Hardware: Other   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: screenshot
Allow newlines in '<num> <gen> obj' sequence

Description octoploid 2016-03-30 08:07:26 UTC
Open http://llvm.org/devmtg/2016-03/Presentations/EuroLLVM%202016-%20New%20LLD%20linker%20for%20ELF.pdf with okular and it will just 
display blank pages.
Comment 1 Albert Astals Cid 2016-03-30 23:49:41 UTC
Works fine here, which poppler version are you using?
Comment 2 octoploid 2016-03-31 07:18:47 UTC
0.42.0 and Okular 0.24.2
Comment 3 octoploid 2016-03-31 07:48:28 UTC
Building with -fsanitize=undefined shows:

poppler-0.42.0/goo/GooString.cc:166:23: runtime error: null pointer passed as argument 2, which is declared to never be null
poppler-0.42.0/poppler/XRef.cc:1199:19: runtime error: load of value 774974790, which is not a valid value for type 'CryptAlgorithm'
poppler-0.42.0/poppler/XRef.cc:427:24: runtime error: load of value 774974790, which is not a valid value for type 'CryptAlgorithm'
poppler-0.42.0/splash/SplashScreen.cc:380:57: runtime error: null pointer passed as argument 1, which is declared to never be null
poppler-0.42.0/splash/SplashScreen.cc:380:57: runtime error: null pointer passed as argument 2, which is declared to never be null
poppler-0.42.0/poppler/TextOutputDev.cc:3357:77: runtime error: null pointer passed as argument 1, which is declared to never be null
Comment 4 octoploid 2016-03-31 11:15:18 UTC
pdftocairo and pdftoppm work fine. So it might be an Okular specific issue.
Comment 5 Albert Astals Cid 2016-03-31 20:28:22 UTC
Can you attach a screenshot?
Comment 6 octoploid 2016-03-31 21:27:23 UTC
Created attachment 122650 [details]
screenshot
Comment 7 Albert Astals Cid 2016-03-31 22:05:09 UTC
Do you build poppler yourself or get it from your distro? If you build it yourself can you try qt4/demos/poppler_qt4viewer and qt4/tests/test-poppler-qt4 and see if they have the same problem?
Comment 8 octoploid 2016-04-01 07:14:58 UTC
(In reply to Albert Astals Cid from comment #7)
> Do you build poppler yourself or get it from your distro? If you build it
> yourself can you try qt4/demos/poppler_qt4viewer and
> qt4/tests/test-poppler-qt4 and see if they have the same problem?

qt4/demos/poppler_qt4viewer works fine.
Comment 9 Albert Astals Cid 2016-04-01 22:34:53 UTC
We can continue this over at bugs.kde.org if you want but honestly i can't see what would make it break so you get to decide where this bug gets stuck until someone has a really great idea of what may be wrong.
Comment 10 octoploid 2016-04-02 09:10:31 UTC
org.kde.okular.core: request observer=0xecb1f80 1044x584@3
org.kde.okular.core: sending request observer=0xecb1f80 1044x584@3 async == true isTile == false
org.kde.okular.generators.pdf: [Poppler] "Error: unable to allocate 0 entries"
org.kde.okular.generators.pdf: [Poppler] "Error: font resource is not a dictionary"
org.kde.okular.generators.pdf: [Poppler] "Error: font resource is not a dictionary"
org.kde.okular.generators.pdf: [Poppler] "Error: font resource is not a dictionary"
org.kde.okular.generators.pdf: [Poppler] "Error: Couldn't find trailer dictionary"
org.kde.okular.generators.pdf: [Poppler] "Error: Weird page contents"
org.kde.okular.generators.pdf: [Poppler] "Error: unable to allocate 0 entries"
org.kde.okular.generators.pdf: [Poppler] "Error: font resource is not a dictionary"
org.kde.okular.generators.pdf: [Poppler] "Error: font resource is not a dictionary"
org.kde.okular.generators.pdf: [Poppler] "Error: font resource is not a dictionary"
org.kde.okular.generators.pdf: [Poppler] "Error: Couldn't find trailer dictionary"
org.kde.okular.generators.pdf: [Poppler] "Error: Weird page contents"
Comment 11 Albert Astals Cid 2016-04-03 16:07:28 UTC
Those are exactly the same errors 
qt4/demos/poppler_qt4viewer should give you, otherwise something is very broken on your system.
Comment 12 Thomas Freitag 2016-04-04 11:22:32 UTC
The reason for blank pages is the solution for bug 92508, Albert. Seems as if You are using okular with an older poppler.
In the catalog dict of that PDF are some object referenced (JavaScript, Outlines) which are not part of the PDF.
But because the xref reconstruction algorithm is not able to reconstruct any xref, the xref table is destroyed and the xref structure is no more usable.

And the reconstruction algorithm doesn't work for that PDF because it doesn't use blanks as delimiter but newlines, i.e. instead of

4 0 obj

there is

4
0
obj

Never saw something like this, but it seems to be legal. I will work on a solution.
Comment 13 Thomas Freitag 2016-04-04 12:11:19 UTC
Created attachment 122699 [details] [review]
Allow newlines in '<num> <gen> obj' sequence

This patch solve it
Comment 14 octoploid 2016-04-04 12:30:09 UTC
(In reply to Thomas Freitag from comment #13)
> Created attachment 122699 [details] [review] [review]
> Allow newlines in '<num> <gen> obj' sequence
> 
> This patch solve it

Thanks. It works fine now.
Comment 15 Albert Astals Cid 2016-04-04 21:40:06 UTC
(In reply to Thomas Freitag from comment #12)
> The reason for blank pages is the solution for bug 92508, Albert. Seems as
> if You are using okular with an older poppler.
> In the catalog dict of that PDF are some object referenced (JavaScript,
> Outlines) which are not part of the PDF.
> But because the xref reconstruction algorithm is not able to reconstruct any
> xref, the xref table is destroyed and the xref structure is no more usable.
> 
> And the reconstruction algorithm doesn't work for that PDF because it
> doesn't use blanks as delimiter but newlines, i.e. instead of
> 
> 4 0 obj
> 
> there is
> 
> 4
> 0
> obj
> 
> Never saw something like this, but it seems to be legal. I will work on a
> solution.

So you mean that we break the xref while trying to reconstruct it?

ouch
Comment 16 Thomas Freitag 2016-04-05 15:11:54 UTC
*** Bug 94830 has been marked as a duplicate of this bug. ***
Comment 17 Albert Astals Cid 2016-04-28 21:53:36 UTC
Pushed

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.