external/boost/UnpackedTarball_boost.mk        |    1 +
 external/boost/windows-no-utf8-locales.patch.0 |   23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)

New commits:
commit b6f2c7a64dd3c80161db630b9b28ad1b228a1c9f
Author:     Mike Kaganski <[email protected]>
AuthorDate: Wed Feb 28 03:48:55 2024 +0600
Commit:     Xisco Fauli <[email protected]>
CommitDate: Wed Feb 28 18:26:37 2024 +0100

    tdf#157135 workaround: restore and update windows-no-utf8-locales.patch.0
    
    This partially reverts commit ed259e5efe432386b54c553cbc644b3b64976852
    (Upgrade external/boost to latest Boost 1.81.0, 2023-01-05), which had
    dropped the patch previously introduced with commit
    f046fed2782f0d4244aff719ba70a56399a2583a (Don't ever attempt to initialise
    a std::locale with a UTF-8 locale on Windows, 2018-05-17).
    
    It seems that there is a nightmare going on in MSVCRT, and tdf#157135
    is caused by dome MS bug. The problem happens in a deeply nested call
    to mbstowcs_s (several levels deep from std::locale constructor with
    name of "en_US.UTF-8"), which gets a non-null wcstr and sizeInWords
    equal to zero, which generates an invalid argument handler, resulting
    in a failed assertion "(pwcs == nullptr && sizeInWords == 0) || (pwcs
    != nullptr && sizeInWords > 0)" in _mbstowcs_internal from
    minkernel    The crashreporter initiates, but since it tries to use CRT 
itself,
    which is in fastfail mode, it hangs.
    
    The patch that is restored here was intended for something different;
    but it happily workarounds the nightmare. Until the proper fix found,
    let it be.
    
    Change-Id: Ic978f87e2e7b81fc2e1cd182a4247084ad016a9f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164068
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>
    (cherry picked from commit 072a25e1ef4815bbef4f18f59f025862a0d8e876)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163985
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/external/boost/UnpackedTarball_boost.mk 
b/external/boost/UnpackedTarball_boost.mk
index d8bd131ac8df..8ab4d7949901 100644
--- a/external/boost/UnpackedTarball_boost.mk
+++ b/external/boost/UnpackedTarball_boost.mk
@@ -26,6 +26,7 @@ boost_patches += boost_1_59_0.property_tree.wreturn-type.patch
 boost_patches += clang-cl.patch.0
 
 boost_patches += boost_1_63_0.undef.warning.patch.1
+boost_patches += windows-no-utf8-locales.patch.0
 
 boost_patches += msvc2017.patch.0
 
diff --git a/external/boost/windows-no-utf8-locales.patch.0 
b/external/boost/windows-no-utf8-locales.patch.0
new file mode 100644
index 000000000000..519d8bde2fe6
--- /dev/null
+++ b/external/boost/windows-no-utf8-locales.patch.0
@@ -0,0 +1,23 @@
+Don't ever attempt to initialise a std::locale with a UTF-8 locale on Windows 
-*- Mode: Diff -*-
+
+--- libs/locale/src/boost/locale/std/std_backend.cpp
++++ libs/locale/src/boost/locale/std/std_backend.cpp
+@@ -86,6 +86,7 @@
+ #endif
+                 utf_mode_ = utf8_support::none;
+             } else {
++                #if !defined(BOOST_WINDOWS)
+                 if(loadable(lid)) {
+                     name_ = lid;
+                     utf_mode_ = utf8_support::native_with_wide;
+@@ -98,8 +99,8 @@
+                     utf_mode_ = utf8_support::from_wide;
+ #endif
+                 }
+-#if defined(BOOST_WINDOWS)
+-                else if(loadable(win_name))
++                #else
++                if(loadable(win_name))
+                 {
+                     name_ = win_name;
+                     utf_mode_ = utf8_support::from_wide;

Reply via email to