Avoid gengal hanging in an --enable-dbgutil build on Windows

Desktop / LibreOffice - Tor Lillqvist [collabora.com] - 11 May 2018 11:45 EDT

With a newer C++ debug runtime (in an --enable-dbgutil build), passing an invalid locale name causes an attempt to display an error dialog. Which does not even show up, at least for me, but instead the process (gengal, at least) just hangs. Which is far from ideal.

Passing a POSIX-style locale name to the std::locale constructor on Windows is a bit odd, but apparently in the normal C++ runtime it "just" causes an exception to be thrown, that boost catches (see the loadable(std::string name) in boost's libs\locale\src\std\std_backend.cpp), and then instead uses the Windows style locale name it knows how to construct. (Why it even tries the POSIX style name on Windows I can't understand.)

Actually it isn't just the locale name part "en_US" of a locale like "en_US.UTF-8" that is problematic, but also the encoding part, "UTF-8". The Microsoft C/C++ library does not support UTF-8 locales. The error message that our own report hook catches says: "f:\dd\vctools\crt\crtw32\stdcpp\xmbtowc.c(89) : Assertion failed: ploc->_Mbcurmax == 1 || ploc->_Mbcurmax == 2". Clearly in a UTF-8 locale (perhaps one that boost internally constructs?) the maximum bytes per character will be more than 2.

With a debug C++ runtime, we need to avoid the error dialog, and just ignore the error. So we install an own CRT error report hook that ignores the error for the duration of the locale construcion.

Change-Id: Ia2ca994f03d1ce94ce7e9d7607f204c320ab8f2d Reviewed-on: https://gerrit.libreoffice.org/54110

2ff121f298e6 Avoid gengal hanging in an --enable-dbgutil build on Windows
unotools/source/i18n/resmgr.cxx | 70 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 69 insertions(+), 1 deletion(-)

Upstream: cgit.freedesktop.org

  • Share