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;