summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-11-11 20:49:13 +0100
committerStephan Bergmann <sbergman@redhat.com>2021-11-11 22:36:31 +0100
commitc36fa9f86e54afa4e1876a9d296ebcbfcbd3a0ad (patch)
tree9d596d44f389a0c2338181970a6e10d41780a213
parentc39749b1472f2719c6de59debd40e793550b5f46 (diff)
external/poppler: Avoid missing typeinfo in UBSan builds
After 03bc0f97205593547ddf1fc8d4fb396479bcab6d "poppler: upgrade to release 21.11.0", my Linux Clang UBSan build started to fail to link Executable_xpdfimport with > ld.lld: error: undefined symbol: SplashOutputDev::SplashOutputDev(SplashColorMode, int, bool, unsigned char*, bool, SplashThinLineMode, bool) > >>> referenced by PSOutputDev.cc:3197 (workdir/UnpackedTarball/poppler/poppler/PSOutputDev.cc:3197) > >>> PSOutputDev.o:(PSOutputDev::checkPageSlice(Page*, double, double, int, bool, bool, int, int, int, int, bool, bool (*)(void*), void*, bool (*)(Annot*, void*), void*)) in archive workdir/LinkTarget/StaticLibrary/libpoppler.a > > ld.lld: error: undefined symbol: SplashOutputDev::startDoc(PDFDoc*) > >>> referenced by PSOutputDev.cc:3206 (workdir/UnpackedTarball/poppler/poppler/PSOutputDev.cc:3206) > >>> PSOutputDev.o:(PSOutputDev::checkPageSlice(Page*, double, double, int, bool, bool, int, int, int, int, bool, bool (*)(void*), void*, bool (*)(Annot*, void*), void*)) in archive workdir/LinkTarget/StaticLibrary/libpoppler.a > > ld.lld: error: undefined symbol: typeinfo for SplashOutputDev > >>> referenced by PSOutputDev.cc > >>> PSOutputDev.o:(.data+0x16208) in archive workdir/LinkTarget/StaticLibrary/libpoppler.a > >>> referenced by PSOutputDev.cc > >>> PSOutputDev.o:(.data+0x162A8) in archive workdir/LinkTarget/StaticLibrary/libpoppler.a > >>> referenced by PSOutputDev.cc > >>> PSOutputDev.o:(.data+0x16348) in archive workdir/LinkTarget/StaticLibrary/libpoppler.a > >>> referenced 6 more times because external/poppler/StaticLibrary_poppler.mk apparently only builds a curated subset of poppler source files, but in a UBSan build the implementation of GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps) in workdir/UnpackedTarball/poppler/poppler/GfxFont.cc (being the only place in Executable_xpdfimport that mentions PSOutputDev, i.e., which is apparently never instantiated in Executable_xpdfimport, and that ps argument is apparently always null) needs the PSOutputDev typeinfo, thus pulling in PSOutputDev.o from StaticLibrary_poppler (which contains the virtual PSOutputDev dtor and thus its typeinfo), which in turn needs the SplashOutputDev ctor and SplashOutputDev::startDoc from within PSOutputDev::checkPageSlice. The obvious fix would be to extend the curated list of source files to include the missing SplashOutputDev symbols, and any symbols recursively needed by those, but that would quickly lead to inclusion of workdir/UnpackedTarball/poppler/splash/SplashFontEngine.cc which would fail to compile due to a missing #include <ft2build.h> from FreeType. So instead of going down that road of adding in ever more stuff, lets try to leave out the problematic definition of PSOutputDev::checkPageSlice (which is apparently never called anyway, see above). But leaving that virtual function out completely would cause missing symbols in the PSOutputDev vtable emitted alongside the PSOputput dtor, but also leaving out that dtor (which is apparently never called anyway, either) would then suppress emission of the PSOutputDev typeinfo, which started this whole exercise. So, just for the UBSan builds, define PSOutputDev::checkPageSlice (never called anyway, see above) with an empty body, as the least invasive approach to avoid the missing typeinfo symbol. Change-Id: Ifcb80501b71f22d8f14ee29fd8e4480871ee36d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125071 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--external/poppler/UnpackedTarball_poppler.mk8
-rw-r--r--external/poppler/sanitizer.patch18
2 files changed, 26 insertions, 0 deletions
diff --git a/external/poppler/UnpackedTarball_poppler.mk b/external/poppler/UnpackedTarball_poppler.mk
index 04fdfc228573..b790693889d3 100644
--- a/external/poppler/UnpackedTarball_poppler.mk
+++ b/external/poppler/UnpackedTarball_poppler.mk
@@ -11,9 +11,17 @@ $(eval $(call gb_UnpackedTarball_UnpackedTarball,poppler))
$(eval $(call gb_UnpackedTarball_set_tarball,poppler,$(POPPLER_TARBALL),,poppler))
+$(eval $(call gb_UnpackedTarball_set_patchlevel,poppler,0))
+
$(eval $(call gb_UnpackedTarball_add_patches,poppler,\
external/poppler/poppler-config.patch.1 \
external/poppler/pch.patch.0 \
))
+ifneq ($(filter -fsanitize=%,$(CC)),)
+$(eval $(call gb_UnpackedTarball_add_patches,poppler, \
+ external/poppler/sanitizer.patch \
+))
+endif
+
# vim: set noet sw=4 ts=4:
diff --git a/external/poppler/sanitizer.patch b/external/poppler/sanitizer.patch
new file mode 100644
index 000000000000..149361661b95
--- /dev/null
+++ b/external/poppler/sanitizer.patch
@@ -0,0 +1,18 @@
+--- poppler/PSOutputDev.cc
++++ poppler/PSOutputDev.cc
+@@ -3111,6 +3111,8 @@
+ bool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, int rotateA, bool useMediaBox, bool crop, int sliceX, int sliceY, int sliceW, int sliceH, bool printing, bool (*abortCheckCbk)(void *data),
+ void *abortCheckCbkData, bool (*annotDisplayDecideCbk)(Annot *annot, void *user_data), void *annotDisplayDecideCbkData)
+ {
++ std::abort();
++#if 0
+ PreScanOutputDev *scan;
+ bool rasterize;
+ bool useFlate, useLZW;
+@@ -3593,5 +3595,6 @@
+
+ return false;
++#endif
+ }
+
+ void PSOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA)