summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <stephan.bergmann@allotropia.de>2024-03-08 12:57:51 +0100
committerStephan Bergmann <stephan.bergmann@allotropia.de>2024-03-08 22:47:30 +0100
commit01067e964a876e38e99a099f62fe514a211a5fca (patch)
tree15b55896c35b8234b72bfe464ff1293c4e28e2a8
parent20f1f529a29fdbc6a531a8c82f4aeff8ff3908bd (diff)
external/skia: Fix a std::sort comparison function's assertion assumptions
At least with a LLVM 19 libc++ in hardening debug mode (where it uses additional invocations of the comparison function passed to std::sort, to verify that the function actually implements a strict weak ordering), chart2_dialogs_test failed with > LO_TEST_LOCALE=en-US > [_RUN_____] Chart2DialogsTest::openAnyDialog > workdir/UnpackedTarball/skia/src/sksl/transform/SkSLFindAndDeclareBuiltinVariables.cpp:112: fatal error: "assert(InterfaceBlockName(*a) != InterfaceBlockName(*b))" apparently because the implementation of std::sort made additional same-arguments calls of operator ()(x, x) that the Skia implementation of the comparison function was not expecting to happen. But the only relevant guarantee that C++20 appears to make for std::sort is that its complexity is O(N log N) comparisons, so any implementation could legitimately do such a "useless" additional same-arguments call of operator ()(x, x) for each of the N elements of the to-be-sorted range. Change-Id: I3a14eb05b5ae9101f37f92e10ecc91a90585de87 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164577 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
-rw-r--r--external/skia/UnpackedTarball_skia.mk1
-rw-r--r--external/skia/sort-comparison-assumption.patch.016
2 files changed, 17 insertions, 0 deletions
diff --git a/external/skia/UnpackedTarball_skia.mk b/external/skia/UnpackedTarball_skia.mk
index 2cdcf62872d3..9e603dcb28dd 100644
--- a/external/skia/UnpackedTarball_skia.mk
+++ b/external/skia/UnpackedTarball_skia.mk
@@ -41,6 +41,7 @@ skia_patches := \
ubsan-missing-typeinfo.patch.1 \
incomplete-type-SkImageGenerator.patch.1 \
0001-AvoidCombiningExtrememelyLargeMeshes.patch.1 \
+ sort-comparison-assumption.patch.0 \
$(eval $(call gb_UnpackedTarball_set_patchlevel,skia,1))
diff --git a/external/skia/sort-comparison-assumption.patch.0 b/external/skia/sort-comparison-assumption.patch.0
new file mode 100644
index 000000000000..b23ae0418123
--- /dev/null
+++ b/external/skia/sort-comparison-assumption.patch.0
@@ -0,0 +1,16 @@
+--- src/sksl/transform/SkSLFindAndDeclareBuiltinVariables.cpp
++++ src/sksl/transform/SkSLFindAndDeclareBuiltinVariables.cpp
+@@ -105,11 +105,11 @@
+ }
+ switch (a->kind()) {
+ case ProgramElement::Kind::kGlobalVar:
+- SkASSERT(GlobalVarBuiltinName(*a) != GlobalVarBuiltinName(*b));
++ SkASSERT(GlobalVarBuiltinName(*a) != GlobalVarBuiltinName(*b) || a == b);
+ return GlobalVarBuiltinName(*a) < GlobalVarBuiltinName(*b);
+
+ case ProgramElement::Kind::kInterfaceBlock:
+- SkASSERT(InterfaceBlockName(*a) != InterfaceBlockName(*b));
++ SkASSERT(InterfaceBlockName(*a) != InterfaceBlockName(*b) || a == b);
+ return InterfaceBlockName(*a) < InterfaceBlockName(*b);
+
+ default: