office-gobmx/external/poppler/sanitizer.patch
Stephan Bergmann c36fa9f86e external/poppler: Avoid missing typeinfo in UBSan builds
After 03bc0f9720 "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>
2021-11-11 22:36:31 +01:00

18 lines
685 B
Diff

--- 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)