Fix (SVG) rasterization crash in qt6 packages

This commit is contained in:
Martchus 2021-06-27 01:27:51 +02:00
parent 316c200a78
commit 5eaf799a5f
14 changed files with 294 additions and 34 deletions

View File

@ -16,7 +16,7 @@
pkgname=<%= $package_name %>
_qtver=6.1.1
pkgver=${_qtver/-/}
pkgrel=1
pkgrel=2
arch=(any)
url='https://www.qt.io'
license=(GPL3 LGPL3 FDL custom)

View File

@ -0,0 +1 @@
../mingw-w64/0008-Fix-crashes-in-rasterization-code-using-setjmp.patch

View File

@ -34,15 +34,17 @@ source=("https://download.qt.io/official_releases/qt/${pkgver%.*}/${_qtver}/subm
'0004-Fix-transitive-dependencies-of-static-libraries.patch'
'0005-Fix-libjpeg-workaround-for-conflict-with-rpcndr.h.patch'
'0006-Support-finding-static-MariaDB-client-library.patch'
'0007-Allow-overriding-CMAKE_FIND_LIBRARY_SUFFIXES-to-pref.patch')
'0007-Allow-overriding-CMAKE_FIND_LIBRARY_SUFFIXES-to-pref.patch'
'0008-Fix-crashes-in-rasterization-code-using-setjmp.patch')
sha256sums=('21a8aa9f07170e047270c668c8b037536f40226db7adbc529a0b41c3a3cb3ff2'
'1b699b33d303275a21f15eeabf7929eb4bb6c0ffc50dc04b818125be9c459f13'
'97ffcc7197b74e3cc5492531249c442cdbf02d231dc55af8f10fb688e383105c'
'9ad76422d221510074241ccabf3880c19c493aaa1f99a222e34ecade0b64a254'
'ea567893e43a23143ec31ff2206a1f221c24588733d55f1d918e9d1dd6746a47'
'a42c48bceb8c80eaa870e362cdf5f92634ca8b54cbbf1f58ed3a72d8be8517f7'
'5361c88bdf85a54b7438c3aea9a12f9d94822b9cd396da2d15741de8acae5a3a'
'dce66f9a271586a46be73689ff64f0d668dfe3f526a3558b3e8ca1169aa711f8')
'0668320d4275eea2d7d772dbb55df4eca37520d931d093dcbd80450aa8d72b25'
'8b261eccf904561520f51b3e5a290336e014410d1e147def8aa8f21a097feed5'
'6b5837037e08da87c70c618ce5f33c3e7031c7593efd10fcb160e41d36e63d6c'
'cb920842d1fc89b181acefab20db5b83ae3f39617ce7b507d9f691768900ae6d'
'5995785ef5837532cafdacf82e639a74f907c49dd344338584d6c3b4d7bb626d'
'1f2b8ef96fb8d3e3c24fc8e0b6e388f1cb6effd2e73d9e6b3d50c8896b055760'
'9d0ea0a2621aea3a1ae8066680a7d41ffda1cc9c9b93ebb3f2219c3b613ab061'
'272950cba900aa0b11b1c7722eed8ce1ff8c8625de97d9815a8d252ddb6ee947')
prepare () {
cd $_pkgfqn

View File

@ -0,0 +1 @@
../mingw-w64/0008-Fix-crashes-in-rasterization-code-using-setjmp.patch

View File

@ -13,7 +13,7 @@
pkgname=mingw-w64-qt6-base-static
_qtver=6.1.1
pkgver=${_qtver/-/}
pkgrel=1
pkgrel=2
arch=(any)
url='https://www.qt.io'
license=(GPL3 LGPL3 FDL custom)
@ -37,15 +37,17 @@ source=("https://download.qt.io/official_releases/qt/${pkgver%.*}/${_qtver}/subm
'0004-Fix-transitive-dependencies-of-static-libraries.patch'
'0005-Fix-libjpeg-workaround-for-conflict-with-rpcndr.h.patch'
'0006-Support-finding-static-MariaDB-client-library.patch'
'0007-Allow-overriding-CMAKE_FIND_LIBRARY_SUFFIXES-to-pref.patch')
'0007-Allow-overriding-CMAKE_FIND_LIBRARY_SUFFIXES-to-pref.patch'
'0008-Fix-crashes-in-rasterization-code-using-setjmp.patch')
sha256sums=('21a8aa9f07170e047270c668c8b037536f40226db7adbc529a0b41c3a3cb3ff2'
'1b699b33d303275a21f15eeabf7929eb4bb6c0ffc50dc04b818125be9c459f13'
'97ffcc7197b74e3cc5492531249c442cdbf02d231dc55af8f10fb688e383105c'
'9ad76422d221510074241ccabf3880c19c493aaa1f99a222e34ecade0b64a254'
'ea567893e43a23143ec31ff2206a1f221c24588733d55f1d918e9d1dd6746a47'
'a42c48bceb8c80eaa870e362cdf5f92634ca8b54cbbf1f58ed3a72d8be8517f7'
'5361c88bdf85a54b7438c3aea9a12f9d94822b9cd396da2d15741de8acae5a3a'
'dce66f9a271586a46be73689ff64f0d668dfe3f526a3558b3e8ca1169aa711f8')
'0668320d4275eea2d7d772dbb55df4eca37520d931d093dcbd80450aa8d72b25'
'8b261eccf904561520f51b3e5a290336e014410d1e147def8aa8f21a097feed5'
'6b5837037e08da87c70c618ce5f33c3e7031c7593efd10fcb160e41d36e63d6c'
'cb920842d1fc89b181acefab20db5b83ae3f39617ce7b507d9f691768900ae6d'
'5995785ef5837532cafdacf82e639a74f907c49dd344338584d6c3b4d7bb626d'
'1f2b8ef96fb8d3e3c24fc8e0b6e388f1cb6effd2e73d9e6b3d50c8896b055760'
'9d0ea0a2621aea3a1ae8066680a7d41ffda1cc9c9b93ebb3f2219c3b613ab061'
'272950cba900aa0b11b1c7722eed8ce1ff8c8625de97d9815a8d252ddb6ee947')
_architectures='i686-w64-mingw32 x86_64-w64-mingw32'

View File

@ -1,7 +1,7 @@
From df9364458a82e26c51c37e8f3cad6a2ca6b828a3 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Thu, 5 Nov 2020 22:08:10 +0100
Subject: [PATCH 1/7] Use CMake's default import library suffix
Subject: [PATCH 1/8] Use CMake's default import library suffix
Change-Id: I3dbedaec74683e5bfd008f7f2fd1e046dfb921b2
---

View File

@ -1,7 +1,7 @@
From dbdccd3fb77932e284848b0a8543133497a3e391 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Wed, 7 Oct 2020 12:13:37 +0200
Subject: [PATCH 2/7] Fix finding D-Bus
Subject: [PATCH 2/8] Fix finding D-Bus
Change-Id: Ie21eb9cbc6b1b5d9c8b34eea46f54718e5926986
---

View File

@ -1,7 +1,7 @@
From 2c85dbecb544e4550587a11df9465c0c662ceaf0 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Thu, 5 Nov 2020 21:13:19 +0100
Subject: [PATCH 3/7] Fix using static PCRE2 and DBus-1
Subject: [PATCH 3/8] Fix using static PCRE2 and DBus-1
When making a static build of Qt we're using the static version of these
libraries and must define the corresponding macros.

View File

@ -1,7 +1,7 @@
From d218fae4376bf0a3b801570164ee6c02e5e94cc0 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Thu, 5 Nov 2020 21:59:33 +0100
Subject: [PATCH 4/7] Fix transitive dependencies (of static libraries)
Subject: [PATCH 4/8] Fix transitive dependencies (of static libraries)
The dependencies of these libraries are not reliably picked up by their
corresponding find modules. This change allows adding the required

View File

@ -1,7 +1,7 @@
From 187e32fa4e8f92796d75f2bd47efb464e4638aec Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Mon, 2 Nov 2020 13:47:45 +0100
Subject: [PATCH 5/7] Fix libjpeg workaround for conflict with rpcndr.h
Subject: [PATCH 5/8] Fix libjpeg workaround for conflict with rpcndr.h
Otherwise it won't compile against mingw-w64-libjpeg-turbo. This version of
libjpeg seems to take care of the conflict already as long as jconfig.h is

View File

@ -1,7 +1,7 @@
From b95bfa5f73b66f31073644a60f04e5740e5a4dec Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Sun, 8 Nov 2020 00:33:12 +0100
Subject: [PATCH 6/7] Support finding static MariaDB client library
Subject: [PATCH 6/8] Support finding static MariaDB client library
We need to reverse the order to look for mariadb first (and only then
for mysql) because otherwise it would pick up the static library

View File

@ -1,7 +1,7 @@
From 8507a185bd7614aa5250495904348ac25ad1b8ac Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Sun, 8 Nov 2020 00:34:09 +0100
Subject: [PATCH 7/7] Allow overriding CMAKE_FIND_LIBRARY_SUFFIXES to prefer
Subject: [PATCH 7/8] Allow overriding CMAKE_FIND_LIBRARY_SUFFIXES to prefer
static libraries
Change-Id: I4c617e0706044d31da1bd56ae51615dc8ed37099

View File

@ -0,0 +1,252 @@
From 4f351792812f2ad38743702ccffa6ccc7e5114da Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Sat, 26 Jun 2021 22:24:12 +0200
Subject: [PATCH 8/8] Fix crashes in rasterization code using setjmp
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Use C++ exceptions instead of setjmp to workaround crashes
* The setjmp/longjmp code crashes when compiling for x86_64-w64-mingw32
with GCC 11 and optimizations enabled¹. It crashes when jumping back
to handle the case of insufficient memory. This change uses C++
exceptions instead (turning the compile unit into a C++ unit instead
of just using C) which should behave identical but don't seem to
crash.
* Fix rendering certain SVGs and possibly other graphics
Change-Id: I01937d13569dd01ab4cb1f608020544c93bc343c
---
¹ See https://bugreports.qt.io/browse/QTBUG-94692 for details.
---
src/gui/CMakeLists.txt | 7 +++-
.../{qgrayraster.c => qgrayraster.cpp} | 41 ++++++++-----------
src/gui/painting/qt_attribution.json | 2 +-
3 files changed, 24 insertions(+), 26 deletions(-)
rename src/gui/painting/{qgrayraster.c => qgrayraster.cpp} (98%)
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index bb21d1b976..6a14076d55 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -166,7 +166,7 @@ qt_internal_add_module(Gui
painting/qdrawingprimitive_sse2_p.h
painting/qemulationpaintengine.cpp painting/qemulationpaintengine_p.h
painting/qfixed_p.h
- painting/qgrayraster.c painting/qgrayraster_p.h
+ painting/qgrayraster.cpp painting/qgrayraster_p.h
painting/qicc.cpp painting/qicc_p.h
painting/qimagescale.cpp
painting/qmemrotate.cpp painting/qmemrotate_p.h
@@ -281,6 +281,11 @@ qt_internal_add_module(Gui
"kernel/qt_gui_pch.h"
)
+# enable exceptions for painting/qgrayraster.cpp
+set_source_files_properties("painting/qgrayraster.cpp"
+ PROPERTIES COMPILE_FLAGS "-fexceptions"
+)
+
# Resources:
set_source_files_properties("../3rdparty/icc/sRGB2014.icc"
PROPERTIES QT_RESOURCE_ALIAS "sRGB2014.icc"
diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.cpp
similarity index 98%
rename from src/gui/painting/qgrayraster.c
rename to src/gui/painting/qgrayraster.cpp
index c6b9aa679e..8952343922 100644
--- a/src/gui/painting/qgrayraster.c
+++ b/src/gui/painting/qgrayraster.cpp
@@ -39,7 +39,7 @@
/***************************************************************************/
/* */
-/* qgrayraster.c, derived from ftgrays.c */
+/* qgrayraster.cpp, derived from ftgrays.c */
/* */
/* A new `perfect' anti-aliasing renderer (body). */
/* */
@@ -157,17 +157,12 @@
# include <vxWorksCommon.h> /* needed for setjmp.h */
#endif
#include <string.h> /* for qt_ft_memcpy() */
-#include <setjmp.h>
#include <limits.h>
#define QT_FT_UINT_MAX UINT_MAX
#define qt_ft_memset memset
-#define qt_ft_setjmp setjmp
-#define qt_ft_longjmp longjmp
-#define qt_ft_jmp_buf jmp_buf
-
#include <stddef.h>
typedef ptrdiff_t QT_FT_PtrDist;
@@ -177,6 +172,8 @@ typedef ptrdiff_t QT_FT_PtrDist;
#define ErrRaster_Memory_Overflow -4
#define ErrRaster_OutOfMemory -6
+struct RasterMemoryOverflow {};
+
#define QT_FT_BEGIN_HEADER
#define QT_FT_END_HEADER
@@ -310,8 +307,6 @@ QT_FT_END_STMNT
int band_size;
int band_shoot;
- qt_ft_jmp_buf jump_buffer;
-
void* buffer;
long buffer_size;
@@ -333,12 +328,14 @@ QT_FT_END_STMNT
} TRaster, *PRaster;
+ extern "C" {
int q_gray_rendered_spans(TRaster *raster)
{
if ( raster && raster->worker )
return raster->worker->skip_spans > 0 ? 0 : -raster->worker->skip_spans;
return 0;
}
+ }
/*************************************************************************/
/* */
@@ -404,7 +401,6 @@ QT_FT_END_STMNT
ras.max_ey = ( ras.max_ey + 63 ) >> 6;
}
-
/*************************************************************************/
/* */
/* Record the current cell in the table. */
@@ -433,7 +429,7 @@ QT_FT_END_STMNT
}
if ( ras.num_cells >= ras.max_cells )
- qt_ft_longjmp( ras.jump_buffer, 1 );
+ throw RasterMemoryOverflow();
cell = ras.cells + ras.num_cells++;
cell->x = x;
@@ -1506,7 +1502,7 @@ QT_FT_END_STMNT
QT_FT_TRACE5(( " move to (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0 ));
- error = gray_move_to( &v_start, user );
+ error = gray_move_to( &v_start, static_cast<PWorker>(user) );
if ( error )
goto Exit;
@@ -1528,7 +1524,7 @@ QT_FT_END_STMNT
QT_FT_TRACE5(( " line to (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0 ));
- gray_render_line(user, UPSCALE(vec.x), UPSCALE(vec.y));
+ gray_render_line(static_cast<PWorker>(user), UPSCALE(vec.x), UPSCALE(vec.y));
continue;
}
@@ -1557,7 +1553,7 @@ QT_FT_END_STMNT
" with control (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
- gray_render_conic(user, &v_control, &vec);
+ gray_render_conic(static_cast<PWorker>(user), &v_control, &vec);
continue;
}
@@ -1571,7 +1567,7 @@ QT_FT_END_STMNT
" with control (%.2f, %.2f)\n",
v_middle.x / 64.0, v_middle.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
- gray_render_conic(user, &v_control, &v_middle);
+ gray_render_conic(static_cast<PWorker>(user), &v_control, &v_middle);
v_control = vec;
goto Do_Conic;
@@ -1581,7 +1577,7 @@ QT_FT_END_STMNT
" with control (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
- gray_render_conic(user, &v_control, &v_start);
+ gray_render_conic(static_cast<PWorker>(user), &v_control, &v_start);
goto Close;
}
@@ -1616,7 +1612,7 @@ QT_FT_END_STMNT
vec.x / 64.0, vec.y / 64.0,
vec1.x / 64.0, vec1.y / 64.0,
vec2.x / 64.0, vec2.y / 64.0 ));
- gray_render_cubic(user, &vec1, &vec2, &vec);
+ gray_render_cubic(static_cast<PWorker>(user), &vec1, &vec2, &vec);
continue;
}
@@ -1625,7 +1621,7 @@ QT_FT_END_STMNT
v_start.x / 64.0, v_start.y / 64.0,
vec1.x / 64.0, vec1.y / 64.0,
vec2.x / 64.0, vec2.y / 64.0 ));
- gray_render_cubic(user, &vec1, &vec2, &v_start);
+ gray_render_cubic(static_cast<PWorker>(user), &vec1, &vec2, &v_start);
goto Close;
}
}
@@ -1634,7 +1630,7 @@ QT_FT_END_STMNT
/* close the contour with a line segment */
QT_FT_TRACE5(( " line to (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0 ));
- gray_render_line(user, UPSCALE(v_start.x), UPSCALE(v_start.y));
+ gray_render_line(static_cast<PWorker>(user), UPSCALE(v_start.x), UPSCALE(v_start.y));
Close:
first = last + 1;
@@ -1662,14 +1658,11 @@ QT_FT_END_STMNT
{
volatile int error = 0;
- if ( qt_ft_setjmp( ras.jump_buffer ) == 0 )
- {
+ try {
error = QT_FT_Outline_Decompose( &ras.outline, &ras );
if ( !ras.invalid )
gray_record_cell( RAS_VAR );
- }
- else
- {
+ } catch (const RasterMemoryOverflow &) {
error = ErrRaster_Memory_Overflow;
}
@@ -1934,7 +1927,7 @@ QT_FT_END_STMNT
static int
gray_raster_new( QT_FT_Raster* araster )
{
- *araster = malloc(sizeof(TRaster));
+ *araster = static_cast<TRaster *>(malloc(sizeof(TRaster)));
if (!*araster) {
*araster = 0;
return ErrRaster_Memory_Overflow;
diff --git a/src/gui/painting/qt_attribution.json b/src/gui/painting/qt_attribution.json
index e2326a56c1..7b30969ec8 100644
--- a/src/gui/painting/qt_attribution.json
+++ b/src/gui/painting/qt_attribution.json
@@ -4,7 +4,7 @@
"Name": "Anti-aliasing rasterizer from FreeType 2",
"QDocModule": "qtgui",
"QtUsage": "Used in Qt GUI.",
- "Path": "qgrayraster.c",
+ "Path": "qgrayraster.cpp",
"Description": "FreeType is a freely available software library to render fonts.",
"Homepage": "http://www.freetype.org",
--
2.32.0

View File

@ -13,7 +13,7 @@
pkgname=mingw-w64-qt6-base
_qtver=6.1.1
pkgver=${_qtver/-/}
pkgrel=1
pkgrel=2
arch=(any)
url='https://www.qt.io'
license=(GPL3 LGPL3 FDL custom)
@ -37,15 +37,17 @@ source=("https://download.qt.io/official_releases/qt/${pkgver%.*}/${_qtver}/subm
'0004-Fix-transitive-dependencies-of-static-libraries.patch'
'0005-Fix-libjpeg-workaround-for-conflict-with-rpcndr.h.patch'
'0006-Support-finding-static-MariaDB-client-library.patch'
'0007-Allow-overriding-CMAKE_FIND_LIBRARY_SUFFIXES-to-pref.patch')
'0007-Allow-overriding-CMAKE_FIND_LIBRARY_SUFFIXES-to-pref.patch'
'0008-Fix-crashes-in-rasterization-code-using-setjmp.patch')
sha256sums=('21a8aa9f07170e047270c668c8b037536f40226db7adbc529a0b41c3a3cb3ff2'
'1b699b33d303275a21f15eeabf7929eb4bb6c0ffc50dc04b818125be9c459f13'
'97ffcc7197b74e3cc5492531249c442cdbf02d231dc55af8f10fb688e383105c'
'9ad76422d221510074241ccabf3880c19c493aaa1f99a222e34ecade0b64a254'
'ea567893e43a23143ec31ff2206a1f221c24588733d55f1d918e9d1dd6746a47'
'a42c48bceb8c80eaa870e362cdf5f92634ca8b54cbbf1f58ed3a72d8be8517f7'
'5361c88bdf85a54b7438c3aea9a12f9d94822b9cd396da2d15741de8acae5a3a'
'dce66f9a271586a46be73689ff64f0d668dfe3f526a3558b3e8ca1169aa711f8')
'0668320d4275eea2d7d772dbb55df4eca37520d931d093dcbd80450aa8d72b25'
'8b261eccf904561520f51b3e5a290336e014410d1e147def8aa8f21a097feed5'
'6b5837037e08da87c70c618ce5f33c3e7031c7593efd10fcb160e41d36e63d6c'
'cb920842d1fc89b181acefab20db5b83ae3f39617ce7b507d9f691768900ae6d'
'5995785ef5837532cafdacf82e639a74f907c49dd344338584d6c3b4d7bb626d'
'1f2b8ef96fb8d3e3c24fc8e0b6e388f1cb6effd2e73d9e6b3d50c8896b055760'
'9d0ea0a2621aea3a1ae8066680a7d41ffda1cc9c9b93ebb3f2219c3b613ab061'
'272950cba900aa0b11b1c7722eed8ce1ff8c8625de97d9815a8d252ddb6ee947')
_architectures='i686-w64-mingw32 x86_64-w64-mingw32'