external/skia/UnpackedTarball_skia.mk            |    1 +
 external/skia/sort-comparison-assumption.patch.0 |   16 ++++++++++++++++
 2 files changed, 17 insertions(+)

New commits:
commit 01067e964a876e38e99a099f62fe514a211a5fca
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Fri Mar 8 12:57:51 2024 +0100
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Fri Mar 8 22:47:30 2024 +0100

    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.bergm...@allotropia.de>

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:

Reply via email to