Sunday, February 02, 2020

Re: WIP: print/scribus (segmentation fault)

>>> > Rafael Sadowski writes:
>>> >
>>> > > Here is an update for scribus to the newest qt5 version. Long time ago
>>> > > Landry tried to update scribus without response from ports@.
>>> > >
>>> > > Here is a new try. Unfortunately this version crashes immediately
>>> > > without a backtrace.
>>> > >
>>> > > Anyone want to take a look at this? I would be very grateful.
>>> > >
>>> > > Diff below includes patches from ArchLinux to unbreak the build with
>>> > > our popper.

I managed to get scribus to work. Here is a diff that additionally:
- deletes DOS line endings using Stuart's hint
- fixes segfault with patches/patch-scribus_ui_colorlistmodel_{cpp,h}

First, I enabled debugging in the port.
DEBUG = -g
CFLAGS = -g
CXXFLAGS = -g

Then, I installed debug-qtbase. The debug packages were helpful.
$ pkg_add debug-qtbase

The debugger shows:
(gdb) run
Starting program: /usr/local/bin/scribus

Program received signal SIGSEGV, Segmentation fault.
0x0000099ac44e44e2 in std::__1::__atomic_base<int, false>::load(std::__1::memory_order) const () from /usr/local/lib/libQt5Core.so.2.2
(gdb) bt
#0 0x0000099ac44e44e2 in std::__1::__atomic_base<int, false>::load(std::__1::memory_order) const () from /usr/local/lib/libQt5Core.so.2.2
#1 0x0000099ac44e4471 in int QAtomicOps<int>::load<int>(std::__1::atomic<int> const&) () from /usr/local/lib/libQt5Core.so.2.2
#2 0x0000099ac44e442f in QBasicAtomicInteger<int>::load() const ()
from /usr/local/lib/libQt5Core.so.2.2
#3 0x0000099ac44e5176 in QtPrivate::RefCount::ref() ()
from /usr/local/lib/libQt5Core.so.2.2
#4 0x0000099ac462fde1 in QString::operator=(QString const&) ()
from /usr/local/lib/libQt5Core.so.2.2
#5 0x00000997f478be60 in _GLOBAL__sub_I_colorlistmodel.cpp ()
at /usr/ports/pobj/scribus-1.5.5/scribus-1.5.5/scribus/ui/colorlistmodel.cpp:13

colorlistmodel.cpp:13 reads:
ColorPixmapValue ColorListModel::m_NoneColor(ScColor(), nullptr,
CommonStrings::None);

in colorlistmodel.h:
//! Dummy object used to represent None Color
static ColorPixmapValue m_NoneColor;

Given frame 4's QString, I think the real problem is with the usage of
CommonStrings::None. I noticed that m_NoneColor was not actually used in
ui/colorlistmodel.{h,cpp} or anywhere else in the project. I just
deleted m_NoneColor and that actually resolved the segfault.

I can poke at it some more to see if there is a more optimal solution,
but at least the program starts up now. If this is sufficient, it should
be ready for testing.

To test the port, I followed the tutorial in Help > Scribus Manual >
Scribus Basics > Quick Start Guide. I was able to make this by following
the tutorial: https://namtsui.com/public/rembrandt.jpg

Feedback and tests are welcome.

Index: Makefile
===================================================================
RCS file: /cvs/ports/print/scribus/Makefile,v
retrieving revision 1.67
diff -u -p -r1.67 Makefile
--- Makefile 12 Jul 2019 20:48:57 -0000 1.67
+++ Makefile 3 Feb 2020 03:08:52 -0000
@@ -1,58 +1,53 @@
# $OpenBSD: Makefile,v 1.67 2019/07/12 20:48:57 sthen Exp $

COMMENT= desktop publishing program
-DISTNAME= scribus-1.4.6
+DISTNAME= scribus-1.5.5
CATEGORIES= print
-REVISION= 3

HOMEPAGE= https://www.scribus.net/

# GPLv2+
PERMIT_PACKAGE= Yes

-WANTLIB += ${COMPILER_LIBCXX} ${MODPY_WANTLIB}
-WANTLIB += QtGui QtNetwork QtXml c cairo cups fontconfig freetype
-WANTLIB += hyphen jpeg lcms2 m podofo tiff xml2 z
-
-COMPILER = base-clang ports-gcc base-gcc
+WANTLIB += ${COMPILER_LIBCXX} Qt5Core Qt5Gui Qt5Network Qt5OpenGL
+WANTLIB += Qt5PrintSupport Qt5Widgets Qt5Xml c cairo cups execinfo
+WANTLIB += fontconfig freetype harfbuzz harfbuzz-icu hunspell-1.6
+WANTLIB += icudata icuuc jpeg lcms2 m podofo poppler ${MODPY_WANTLIB}
+WANTLIB += tiff util xml2 z

MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=scribus/}
-
EXTRACT_SUFX= .tar.xz

-MODULES= x11/qt4 \
+MODULES= x11/qt5 \
devel/cmake \
lang/python

-MODPY_RUNDEP= No
-
BUILD_DEPENDS= devel/boost
+
RUN_DEPENDS= devel/desktop-file-utils \
graphics/py-Pillow \
+ misc/shared-mime-info \
print/ghostscript/gnu \
textproc/antiword \
- misc/shared-mime-info \
${MODPY_TKINTER_DEPENDS}
-LIB_DEPENDS= graphics/lcms2 \
+
+LIB_DEPENDS= devel/harfbuzz,-icu \
+ graphics/jpeg \
+ graphics/lcms2 \
graphics/tiff \
print/cups,-libs \
- textproc/hyphen \
+ print/poppler \
+ textproc/hunspell \
textproc/libxml \
textproc/podofo \
- graphics/jpeg \
${MODPY_LIB_DEPENDS}

-FLAVORS= debug
-FLAVOR?=
+CONFIGURE_ARGS+= -DCMAKE_INSTALL_MANDIR="${LOCALBASE}/man/"

-CONFIGURE_ARGS += -DCMAKE_SKIP_RPATH:BOOL=1 \
- -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
- -DCMAKE_C_FLAGS="${CFLAGS}" \
- -DMANDIR="${LOCALBASE}/man/"
-
-.if ${FLAVOR:Mdebug}
-CONFIGURE_ARGS+=-DWANT_DEBUG=1
-.endif
+# delete DOS line endings
+post-extract:
+ @find ${WRKSRC} -type f -name "*.cpp" | xargs perl -i -pe 's/\r$$//'
+ @find ${WRKSRC} -type f -name "*.h" | xargs perl -i -pe 's/\r$$//'

post-install:
@${INSTALL_DATA_DIR} ${PREFIX}/share/applications
Index: distinfo
===================================================================
RCS file: /cvs/ports/print/scribus/distinfo,v
retrieving revision 1.12
diff -u -p -r1.12 distinfo
--- distinfo 13 Apr 2018 20:51:12 -0000 1.12
+++ distinfo 3 Feb 2020 03:08:52 -0000
@@ -1,2 +1,2 @@
-SHA256 (scribus-1.4.6.tar.xz) = IeM2UA2e3JyQzPcwh+XvPfWew+Sjy/7BU2e82NB4oZo=
-SIZE (scribus-1.4.6.tar.xz) = 73601104
+SHA256 (scribus-1.5.5.tar.xz) = eQiyGmzoQyafWM7fX495GJMlfmIBzOX73ccNrKL+P3E=
+SIZE (scribus-1.5.5.tar.xz) = 73861836
Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: patches/patch-CMakeLists_txt
diff -N patches/patch-CMakeLists_txt
--- patches/patch-CMakeLists_txt 13 Apr 2018 20:51:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,24 +0,0 @@
-$OpenBSD: patch-CMakeLists_txt,v 1.3 2018/04/13 20:51:12 sthen Exp $
-Index: CMakeLists.txt
---- CMakeLists.txt.orig
-+++ CMakeLists.txt
-@@ -275,7 +275,9 @@ ENDIF (APPLEBUNDLE)
- #Setp all the directories we will use
- #MAN
- CMAKE_POLICY(SET CMP0005 OLD)
--SET(MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man/")
-+IF(!MANDIR)
-+ SET(MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man/")
-+ENDIF(MANDIR)
- IF(WANT_VERSIONING)
- SET(SHAREDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/")
- ELSE(WANT_VERSIONING)
-@@ -374,7 +376,7 @@ IF(WANT_LIB64)
- ENDIF(NOT ARCH_X86_64)
- SET(LIB_SUFFIX "64" CACHE TYPE STRING)
- ENDIF(WANT_LIB64)
--SET(LIB_DIR_NAME "lib${LIB_SUFFIX}")
-+SET(LIB_DIR_NAME "lib")
- IF (APPLEBUNDLE)
- SET(LIBDIR "lib/")
- ELSE (APPLEBUNDLE)
Index: patches/patch-resources_manpages_CMakeLists_txt
===================================================================
RCS file: patches/patch-resources_manpages_CMakeLists_txt
diff -N patches/patch-resources_manpages_CMakeLists_txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-resources_manpages_CMakeLists_txt 3 Feb 2020 03:08:52 -0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+
+Index: resources/manpages/CMakeLists.txt
+--- resources/manpages/CMakeLists.txt.orig
++++ resources/manpages/CMakeLists.txt
+@@ -7,15 +7,3 @@ scribus.1
+ DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
+ RENAME scribus${TAG_VERSION}.1
+ )
+-
+-install(FILES
+-scribus.1.de
+- DESTINATION ${CMAKE_INSTALL_MANDIR}/de/man1
+- RENAME scribus${TAG_VERSION}.1
+-)
+-
+-install(FILES
+-scribus.1.pl
+- DESTINATION ${CMAKE_INSTALL_MANDIR}/pl/man1
+- RENAME scribus${TAG_VERSION}.1
+-)
Index: patches/patch-scribus_CMakeLists_txt
===================================================================
RCS file: patches/patch-scribus_CMakeLists_txt
diff -N patches/patch-scribus_CMakeLists_txt
--- patches/patch-scribus_CMakeLists_txt 13 Apr 2018 20:51:12 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,18 +0,0 @@
-$OpenBSD: patch-scribus_CMakeLists_txt,v 1.1 2018/04/13 20:51:12 sthen Exp $
-
-Index: scribus/CMakeLists.txt
---- scribus/CMakeLists.txt.orig
-+++ scribus/CMakeLists.txt
-@@ -791,10 +791,9 @@ IF(UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" A
- TARGET_LINK_LIBRARIES(${EXE_NAME} dl)
- ENDIF(UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT HAIKU)
-
--# #9311 for the OpenBSD addition
--IF(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
-+IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
- TARGET_LINK_LIBRARIES(${EXE_NAME} util execinfo)
--ENDIF(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
-+ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
-
- IF(WIN32)
- TARGET_LINK_LIBRARIES(${EXE_NAME} ${QT_QTMAIN_LIBRARY})
Index: patches/patch-scribus_gtdialogs_cpp
===================================================================
RCS file: patches/patch-scribus_gtdialogs_cpp
diff -N patches/patch-scribus_gtdialogs_cpp
--- patches/patch-scribus_gtdialogs_cpp 21 Jan 2019 21:19:48 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,14 +0,0 @@
-$OpenBSD: patch-scribus_gtdialogs_cpp,v 1.1 2019/01/21 21:19:48 naddy Exp $
-
-Index: scribus/gtdialogs.cpp
---- scribus/gtdialogs.cpp.orig
-+++ scribus/gtdialogs.cpp
-@@ -160,7 +160,7 @@ bool gtDialogs::runImporterDialog(const QStringList& i
- if (imp != "false")
- {
- res = imp;
-- if (importers.contains(res) > 0)
-+ if (importers.contains(res))
- ok = true;
- }
-
Index: patches/patch-scribus_plugins_import_pdf_importpdf_cpp
===================================================================
RCS file: patches/patch-scribus_plugins_import_pdf_importpdf_cpp
diff -N patches/patch-scribus_plugins_import_pdf_importpdf_cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-scribus_plugins_import_pdf_importpdf_cpp 3 Feb 2020 03:08:52 -0000
@@ -0,0 +1,88 @@
+$OpenBSD$
+
+Index: scribus/plugins/import/pdf/importpdf.cpp
+--- scribus/plugins/import/pdf/importpdf.cpp.orig
++++ scribus/plugins/import/pdf/importpdf.cpp
+@@ -75,7 +75,11 @@ PdfPlug::PdfPlug(ScribusDoc* doc, int flags)
+ QImage PdfPlug::readThumbnail(const QString& fName)
+ {
+ QString pdfFile = QDir::toNativeSeparators(fName);
++#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 83, 0)
++ globalParams.reset(new GlobalParams());
++#else
+ globalParams = new GlobalParams();
++

No comments:

Post a Comment