update print/poppler (annoying as always)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

update print/poppler (annoying as always)

Matthias Kilian
Hi,

untested, breakage so far is editors/libreoffice -- i'm  waiting
for dpb to pick it up again after i hopefully fixed it.

If anyone wants to beat me and to test (-build) other ports using
it, be aware that there are some changes where unique_ptr<LinkAction>
are now used instead of LinkAction *.

Ciao,
        Kili

Index: Makefile
===================================================================
RCS file: /cvs/ports/print/poppler/Makefile,v
retrieving revision 1.154
diff -u -p -r1.154 Makefile
--- Makefile 22 Feb 2020 18:55:24 -0000 1.154
+++ Makefile 6 Mar 2020 21:10:28 -0000
@@ -4,7 +4,7 @@ COMMENT-main= PDF rendering library
 COMMENT-qt5= Qt5 interface to PDF rendering library
 COMMENT-utils= PDF conversion tools and utilities
 
-V= 0.85.0
+V= 0.86.1
 DISTNAME= poppler-$V
 CATEGORIES= print
 PKGNAME-main= poppler-$V
@@ -16,10 +16,10 @@ REVISION-qt5= 0
 
 EXTRACT_SUFX= .tar.xz
 
-SHARED_LIBS += poppler              60.0     # 95.0
+SHARED_LIBS += poppler              61.0     # 97.0
 SHARED_LIBS += poppler-glib         19.4     # 8.15
-SHARED_LIBS += poppler-qt5          8.1      # 1.22
-SHARED_LIBS += poppler-cpp          15.0     # 0.7
+SHARED_LIBS += poppler-qt5          8.2      # 1.22
+SHARED_LIBS += poppler-cpp          16.0     # 0.7
 
 HOMEPAGE= https://poppler.freedesktop.org/
 
Index: distinfo
===================================================================
RCS file: /cvs/ports/print/poppler/distinfo,v
retrieving revision 1.80
diff -u -p -r1.80 distinfo
--- distinfo 17 Feb 2020 20:33:00 -0000 1.80
+++ distinfo 6 Mar 2020 21:10:28 -0000
@@ -1,2 +1,2 @@
-SHA256 (poppler-0.85.0.tar.xz) = K8h16zIwAq5rKH4JmARzUY4rLta1t9LhCJ42ps0A2Us=
-SIZE (poppler-0.85.0.tar.xz) = 1588616
+SHA256 (poppler-0.86.1.tar.xz) = r2MKJ3yOGUwxM5xURiQYNK7W7T1LTccIAxHlHGYlf2w=
+SIZE (poppler-0.86.1.tar.xz) = 1593856
Index: patches/patch-poppler_XRef_cc
===================================================================
RCS file: /cvs/ports/print/poppler/patches/patch-poppler_XRef_cc,v
retrieving revision 1.22
diff -u -p -r1.22 patch-poppler_XRef_cc
--- patches/patch-poppler_XRef_cc 19 Jun 2019 19:39:14 -0000 1.22
+++ patches/patch-poppler_XRef_cc 6 Mar 2020 21:10:28 -0000
@@ -2,7 +2,7 @@ $OpenBSD: patch-poppler_XRef_cc,v 1.22 2
 Index: poppler/XRef.cc
 --- poppler/XRef.cc.orig
 +++ poppler/XRef.cc
-@@ -1013,49 +1013,38 @@ void XRef::getEncryptionParameters(unsigned char **fil
+@@ -1042,49 +1042,38 @@ bool XRef::isRefEncrypted(Ref r)
  }
 
  bool XRef::okToPrint(bool ignoreOwnerPW) const {

Reply | Threaded
Open this post in threaded view
|

Re: update print/poppler (annoying as always)

Matthias Kilian
Hi,

On Fri, Mar 06, 2020 at 10:20:33PM +0100, Matthias Kilian wrote:
> untested, breakage so far is editors/libreoffice -- i'm  waiting
> for dpb to pick it up again after i hopefully fixed it.

Unfortunately, this has to be deferred a little bit. I found a (new)
error while running evince on one of my toxic test PDFs ("toxic"
in the sense that they used to trigger bugs in poppler, xpdf etc.
in older versions).

Even more unfortunately, I don't remember who sent me that specific
file and thus don't know wether it's ok to attach it to a bug report
for the poppler people. In case it rings a bell:

-rw-------  1 kili  kili  3909884 Apr  7  2007 PLANHALF.pdf

(That's the date I *received* the file)

Oh, and just for the joy of it:

...
Core was generated by `evince'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  build_goto_dest (document=<optimized out>, action=<optimized out>, link=0x0) at /home/ports/pobj/p2/poppler-0.86.1/poppler-0.86.1/glib/poppler-action.cc:348
348             if (! link->isOk ()) {
[Current thread is 1 (process 435846)]
(gdb) print link
$1 = (const LinkGoTo *) 0x0
(gdb) up
#1  _poppler_action_new (document=0x280b77b5c00, link=0x2812b023d40, title=<optimized out>) at /home/ports/pobj/p2/poppler-0.86.1/poppler-0.86.1/glib/poppler-action.cc:630
630                     build_goto_dest (document, action, dynamic_cast <const LinkGoTo *> (link));
(gdb) print link
$2 = (const LinkAction *) 0x2812b023d40
(gdb)

I'm not a C++ magician, especially if it comes to things like that
dynamic_cast, but it really looks odd to me that this pointer is
NULL in the callee while it's not NULL in the caller.

Ciao,
        Kili

Reply | Threaded
Open this post in threaded view
|

Re: update print/poppler (annoying as always)

Greg Steuck
In reply to this post by Matthias Kilian
Hi Matthias,

> #0  build_goto_dest (document=<optimized out>, action=<optimized out>,
link=0x0) at \
>
/home/ports/pobj/p2/poppler-0.86.1/poppler-0.86.1/glib/poppler-action.cc:348
348      \
> if (! link->isOk ()) { [Current thread is 1 (process 435846)]
> (gdb) print link
> $1 = (const LinkGoTo *) 0x0
> (gdb) up
> #1  _poppler_action_new (document=0x280b77b5c00, link=0x2812b023d40,
title=<optimized \
> out>) at
/home/ports/pobj/p2/poppler-0.86.1/poppler-0.86.1/glib/poppler-action.cc:630
\
> 630                     build_goto_dest (document, action, dynamic_cast
<const \
> LinkGoTo *> (link)); (gdb) print link
> $2 = (const LinkAction *) 0x2812b023d40
> (gdb)

> I'm not a C++ magician, especially if it comes to things like that
> dynamic_cast, but it really looks odd to me that this pointer is
> NULL in the callee while it's not NULL in the caller.

I hope I'm not belaboring the obvious here. This condition seems a
fairly direct result of an unchecked dynamic_cast.  Per C++
dynamic_cast description:

"If the cast fails and new-type is a pointer type, it returns a null
pointer of that type."
https://en.cppreference.com/w/cpp/language/dynamic_cast

This just means that the downcast was a mistake, LinkAction* is NOT a
LinkGoTo*, but some other subclass of LinkAction of which there is a
bunch:

Link.h:161:class LinkGoTo: public LinkAction {
Link.h:187:class LinkGoToR: public LinkAction {
Link.h:216:class LinkLaunch: public LinkAction {
Link.h:240:class LinkURI: public LinkAction {
Link.h:263:class LinkNamed: public LinkAction {
Link.h:285:class LinkMovie: public LinkAction {
Link.h:324:class LinkRendition: public LinkAction {
Link.h:372:class LinkSound: public LinkAction {
Link.h:400:class LinkJavaScript: public LinkAction {
Link.h:422:class LinkOCGState: public LinkAction {
Link.h:453:class LinkHide: public LinkAction {
Link.h:486:class LinkUnknown: public LinkAction {

I don't see how this can be the case if type safety were respected.
The only place where actionGoTo is returned from getKind is in
LinkGoTo class. Though I can't say I'm surprised, the number of
static_cast and C-style casts around these types is so high
I won't expect any type safety in the program.

If one wanted to paper over the problem they could rewrite
_poppler_action_new
"defensively" and make the program fallback locally to
POPPLER_ACTION_NONE. This would avoid the crash, but I suspect the
memory is borked by that point and something else will crash instead.

Out of curiosity, is MALLOC_OPTIONS any help? If repro is easy, maybe
rebuild on an OS with ASan support and see what you get from that?

Thanks
Greg

--
nest.cx is Gmail hosted, use PGP:
https://pgp.key-server.io/0x0B1542BD8DF5A1B0
Fingerprint: 5E2B 2D0E 1E03 2046 BEC3  4D50 0B15 42BD 8DF5 A1B0
Reply | Threaded
Open this post in threaded view
|

Re: update print/poppler (annoying as always)

Matthias Kilian
Hi,

On Sat, Mar 14, 2020 at 04:54:55PM -0700, Greg Steuck wrote:

>
> > #0  build_goto_dest (document=<optimized out>, action=<optimized out>, link=0x0) at \
> > /home/ports/pobj/p2/poppler-0.86.1/poppler-0.86.1/glib/poppler-action.cc:348 348      \
> > if (! link->isOk ()) { [Current thread is 1 (process 435846)]
> > (gdb) print link
> > $1 = (const LinkGoTo *) 0x0
> > (gdb) up
> > #1  _poppler_action_new (document=0x280b77b5c00, link=0x2812b023d40, title=<optimized \
> > out>) at /home/ports/pobj/p2/poppler-0.86.1/poppler-0.86.1/glib/poppler-action.cc:630 \
> > 630                     build_goto_dest (document, action, dynamic_cast <const \
> > LinkGoTo *> (link)); (gdb) print link
> > $2 = (const LinkAction *) 0x2812b023d40
> > (gdb)
>
> > I'm not a C++ magician, especially if it comes to things like that
> > dynamic_cast, but it really looks odd to me that this pointer is
> > NULL in the callee while it's not NULL in the caller.
>
> I hope I'm not belaboring the obvious here. This condition seems a
> fairly direct result of an unchecked dynamic_cast.  Per C++
> dynamic_cast description:
>
> "If the cast fails and new-type is a pointer type, it returns a null
> pointer of that type."
> https://en.cppreference.com/w/cpp/language/dynamic_cast
>
> This just means that the downcast was a mistake, LinkAction* is NOT a
> LinkGoTo*, but some other subclass of LinkAction of which there is a
> bunch:
[...]

There's a commit upstream that just changes all those dynamic_casts to
static_casts (see complete new diff below). Allthough this looks even
more wrong, it doesn't cause a segmentation fault any longer (but maybe
some completely garbaged object?).

[...]

> Out of curiosity, is MALLOC_OPTIONS any help? If repro is easy, maybe
> rebuild on an OS with ASan support and see what you get from that?

No, MALLOC_OPTIONS=S didn't change anyting for me.

So, new diff with that dynamic_cast -> static_cast commit
(68b6dd2ecd868c1a757cb8b9273e2e26687e5229) included, but I'm unsure
what to do. It probably will be in the next release of poppler.

Ciao,
        Kili


Index: Makefile
===================================================================
RCS file: /cvs/ports/print/poppler/Makefile,v
retrieving revision 1.154
diff -u -p -r1.154 Makefile
--- Makefile 22 Feb 2020 18:55:24 -0000 1.154
+++ Makefile 20 Mar 2020 13:08:24 -0000
@@ -4,7 +4,7 @@ COMMENT-main= PDF rendering library
 COMMENT-qt5= Qt5 interface to PDF rendering library
 COMMENT-utils= PDF conversion tools and utilities
 
-V= 0.85.0
+V= 0.86.1
 DISTNAME= poppler-$V
 CATEGORIES= print
 PKGNAME-main= poppler-$V
@@ -16,10 +16,10 @@ REVISION-qt5= 0
 
 EXTRACT_SUFX= .tar.xz
 
-SHARED_LIBS += poppler              60.0     # 95.0
+SHARED_LIBS += poppler              61.0     # 97.0
 SHARED_LIBS += poppler-glib         19.4     # 8.15
-SHARED_LIBS += poppler-qt5          8.1      # 1.22
-SHARED_LIBS += poppler-cpp          15.0     # 0.7
+SHARED_LIBS += poppler-qt5          8.2      # 1.22
+SHARED_LIBS += poppler-cpp          16.0     # 0.7
 
 HOMEPAGE= https://poppler.freedesktop.org/
 
Index: distinfo
===================================================================
RCS file: /cvs/ports/print/poppler/distinfo,v
retrieving revision 1.80
diff -u -p -r1.80 distinfo
--- distinfo 17 Feb 2020 20:33:00 -0000 1.80
+++ distinfo 20 Mar 2020 13:08:24 -0000
@@ -1,2 +1,2 @@
-SHA256 (poppler-0.85.0.tar.xz) = K8h16zIwAq5rKH4JmARzUY4rLta1t9LhCJ42ps0A2Us=
-SIZE (poppler-0.85.0.tar.xz) = 1588616
+SHA256 (poppler-0.86.1.tar.xz) = r2MKJ3yOGUwxM5xURiQYNK7W7T1LTccIAxHlHGYlf2w=
+SIZE (poppler-0.86.1.tar.xz) = 1593856
Index: patches/patch-glib_poppler-action_cc
===================================================================
RCS file: patches/patch-glib_poppler-action_cc
diff -N patches/patch-glib_poppler-action_cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-glib_poppler-action_cc 20 Mar 2020 13:08:24 -0000
@@ -0,0 +1,58 @@
+$OpenBSD$
+
+Upstream commit 68b6dd2ecd868c1a757cb8b9273e2e26687e5229:
+Replace dynamic_cast by static_cast where we already perform the
+type checks explicitly before downcasting.
+
+Index: glib/poppler-action.cc
+--- glib/poppler-action.cc.orig
++++ glib/poppler-action.cc
+@@ -627,39 +627,39 @@ _poppler_action_new (PopplerDocument *document,
+ switch (link->getKind ()) {
+ case actionGoTo:
+ action->type = POPPLER_ACTION_GOTO_DEST;
+- build_goto_dest (document, action, dynamic_cast <const LinkGoTo *> (link));
++ build_goto_dest (document, action, static_cast <const LinkGoTo *> (link));
+ break;
+ case actionGoToR:
+ action->type = POPPLER_ACTION_GOTO_REMOTE;
+- build_goto_remote (action, dynamic_cast <const LinkGoToR *> (link));
++ build_goto_remote (action, static_cast <const LinkGoToR *> (link));
+ break;
+ case actionLaunch:
+ action->type = POPPLER_ACTION_LAUNCH;
+- build_launch (action, dynamic_cast <const LinkLaunch *> (link));
++ build_launch (action, static_cast <const LinkLaunch *> (link));
+ break;
+ case actionURI:
+ action->type = POPPLER_ACTION_URI;
+- build_uri (action, dynamic_cast <const LinkURI *> (link));
++ build_uri (action, static_cast <const LinkURI *> (link));
+ break;
+ case actionNamed:
+ action->type = POPPLER_ACTION_NAMED;
+- build_named (action, dynamic_cast <const LinkNamed *> (link));
++ build_named (action, static_cast <const LinkNamed *> (link));
+ break;
+ case actionMovie:
+ action->type = POPPLER_ACTION_MOVIE;
+- build_movie (document, action, dynamic_cast<const LinkMovie*> (link));
++ build_movie (document, action, static_cast<const LinkMovie*> (link));
+ break;
+ case actionRendition:
+ action->type = POPPLER_ACTION_RENDITION;
+- build_rendition (action, dynamic_cast<const LinkRendition*> (link));
++ build_rendition (action, static_cast<const LinkRendition*> (link));
+ break;
+ case actionOCGState:
+ action->type = POPPLER_ACTION_OCG_STATE;
+- build_ocg_state (document, action, dynamic_cast<const LinkOCGState*> (link));
++ build_ocg_state (document, action, static_cast<const LinkOCGState*> (link));
+ break;
+ case actionJavaScript:
+ action->type = POPPLER_ACTION_JAVASCRIPT;
+- build_javascript (action, dynamic_cast<const LinkJavaScript*> (link));
++ build_javascript (action, static_cast<const LinkJavaScript*> (link));
+ break;
+ case actionUnknown:
+ default:
Index: patches/patch-poppler_XRef_cc
===================================================================
RCS file: /cvs/ports/print/poppler/patches/patch-poppler_XRef_cc,v
retrieving revision 1.22
diff -u -p -r1.22 patch-poppler_XRef_cc
--- patches/patch-poppler_XRef_cc 19 Jun 2019 19:39:14 -0000 1.22
+++ patches/patch-poppler_XRef_cc 20 Mar 2020 13:08:24 -0000
@@ -2,7 +2,7 @@ $OpenBSD: patch-poppler_XRef_cc,v 1.22 2
 Index: poppler/XRef.cc
 --- poppler/XRef.cc.orig
 +++ poppler/XRef.cc
-@@ -1013,49 +1013,38 @@ void XRef::getEncryptionParameters(unsigned char **fil
+@@ -1042,49 +1042,38 @@ bool XRef::isRefEncrypted(Ref r)
  }
 
  bool XRef::okToPrint(bool ignoreOwnerPW) const {
Index: patches/patch-utils_HtmlOutputDev_cc
===================================================================
RCS file: patches/patch-utils_HtmlOutputDev_cc
diff -N patches/patch-utils_HtmlOutputDev_cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-utils_HtmlOutputDev_cc 20 Mar 2020 13:08:24 -0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+
+Upstream commit 68b6dd2ecd868c1a757cb8b9273e2e26687e5229:
+Replace dynamic_cast by static_cast where we already perform the
+type checks explicitly before downcasting.
+
+Index: utils/HtmlOutputDev.cc
+--- utils/HtmlOutputDev.cc.orig
++++ utils/HtmlOutputDev.cc
+@@ -1838,7 +1838,7 @@ int HtmlOutputDev::getOutlinePageNum(OutlineItem *item
+     if (!action || action->getKind() != actionGoTo)
+         return pagenum;
+
+-    link = dynamic_cast<const LinkGoTo*>(action);
++    link = static_cast<const LinkGoTo*>(action);
+
+     if (!link || !link->isOk())
+         return pagenum;