initialization-order-fiasco
commit71d0c43fb4cf535239cb41baf7b6e03de765ce7a
authorStephan Bergmann <sbergman@redhat.com>
Mon, 2 Aug 2021 13:41:53 +0000 (2 15:41 +0200)
committerStephan Bergmann <sbergman@redhat.com>
Mon, 2 Aug 2021 15:09:49 +0000 (2 17:09 +0200)
tree09a931cc275ae9563bfde9fdec589574b2e121fc
parent0f3497ea6080df72d479a405886316da21e35885
initialization-order-fiasco

...after a943936eeff04b60ebd0b2552bc18b42606f3321 "rtl::Static -> static local"
(and the relevant static isn't even local), when building e.g.
Gallery/backgrounds, see <https://ci.libreoffice.org/job/lo_ubsan/2090/>:

> ==26993==ERROR: AddressSanitizer: initialization-order-fiasco on address 0x2b52e50be408 at pc 0x2b52e4d32753 bp 0x7fff5670f090 sp 0x7fff5670f088
> READ of size 8 at 0x2b52e50be408 thread T0
>     #0 0x2b52e4d32752 in std::_Rb_tree<rtl::OUString, std::pair<rtl::OUString const, std::shared_ptr<LanguageTagImpl> >, std::_Select1st<std::pair<rtl::OUString const, std::shared_ptr<LanguageTagImpl> > >, (anonymous namespace)::compareIgnoreAsciiCaseLess, std::allocator<std::pair<rtl::OUString const, std::shared_ptr<LanguageTagImpl> > > >::_M_begin() /home/tdf/lode/opt_private/gcc-7.3.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_tree.h:737:64
>     #1 0x2b52e4d355f3 in std::_Rb_tree<rtl::OUString, std::pair<rtl::OUString const, std::shared_ptr<LanguageTagImpl> >, std::_Select1st<std::pair<rtl::OUString const, std::shared_ptr<LanguageTagImpl> > >, (anonymous namespace)::compareIgnoreAsciiCaseLess, std::allocator<std::pair<rtl::OUString const, std::shared_ptr<LanguageTagImpl> > > >::find(rtl::OUString const&) /home/tdf/lode/opt_private/gcc-7.3.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_tree.h:2523:37
>     #2 0x2b52e4d3507d in std::__cxx1998::map<rtl::OUString, std::shared_ptr<LanguageTagImpl>, (anonymous namespace)::compareIgnoreAsciiCaseLess, std::allocator<std::pair<rtl::OUString const, std::shared_ptr<LanguageTagImpl> > > >::find(rtl::OUString const&) /home/tdf/lode/opt_private/gcc-7.3.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_map.h:1164:21
>     #3 0x2b52e4cf116c in std::__debug::map<rtl::OUString, std::shared_ptr<LanguageTagImpl>, (anonymous namespace)::compareIgnoreAsciiCaseLess, std::allocator<std::pair<rtl::OUString const, std::shared_ptr<LanguageTagImpl> > > >::find(rtl::OUString const&) /home/tdf/lode/opt_private/gcc-7.3.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/debug/map.h:561:32
>     #4 0x2b52e4d00dcd in LanguageTag::registerImpl() const /i18nlangtag/source/languagetag/languagetag.cxx:888:50
>     #5 0x2b52e4cdf693 in LanguageTag::getImpl() /i18nlangtag/source/languagetag/languagetag.cxx:1004:18
>     #6 0x2b52e4cdf3fd in LanguageTag::LanguageTag(rtl::OUString const&, bool) /i18nlangtag/source/languagetag/languagetag.cxx:489:9
>     #7 0x2b52b9aed628 in __cxx_global_var_init.2 /sfx2/source/view/lokhelper.cxx:77:13
>     #8 0x2b52b9aed75e in _GLOBAL__sub_I_lokhelper.cxx /sfx2/source/view/lokhelper.cxx
>     #9 0x2b52b4f069c2 in _dl_init_internal (/lib64/ld-linux-x86-64.so.2+0xf9c2)
>     #10 0x2b52b4ef8179  (/lib64/ld-linux-x86-64.so.2+0x1179)
>
> 0x2b52e50be408 is located 40 bytes inside of global variable '(anonymous namespace)::theMapBcp47' defined in '/home/tdf/lode/jenkins/workspace/lo_ubsan/i18nlangtag/source/languagetag/languagetag.cxx:93:10' (0x2b52e50be3e0) of size 72
>   registered at:
>     #0 0x43f4c8 in __asan_register_globals.part.13 /home/tdf/lode/packages/llvm-llvmorg-9.0.1.src/compiler-rt/lib/asan/asan_globals.cc:362
>     #1 0x2b52e4d4031b in asan.module_ctor (/instdir/program/libi18nlangtag.so+0x16831b)
> LLVMSymbolizer: error reading file: No such file or directory
>     #2 0x7fff567143b7  ([stack]+0x203b7)

This is a partial revert of a943936eeff04b60ebd0b2552bc18b42606f3321
"rtl::Static -> static local".

Change-Id: I5d6803d217d4e8927b5864b2392f3ddd18310a5a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119882
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
i18nlangtag/source/languagetag/languagetag.cxx