summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-03-01 13:46:32 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-03-01 17:55:52 +0100
commit35f1e9c7f97ed08dcb87e90cb663ae2d333739e5 (patch)
tree51d3e1c23faebfa7db958e255e24de6736c6e59b
parent44a403d5a63b16e04b1c66ded6ef4e3bda605ab3 (diff)
fix data races in cclass_Unicode
WARNING: ThreadSanitizer: data race (pid=1220516) Write of size 4 at 0x7b1c00035510 by thread T19 (mutexes: write M0): i18npool::Transliteration_casemapping::setMappingType(MappingType, com::sun::star::lang::Locale const&) :? (libi18npoollo.so+0xe5685) i18npool::cclass_Unicode::toUpper(rtl::OUString const&, int, int, com::sun::star::lang::Locale const&) :? (libi18npoollo.so+0x792fa) i18npool::CharacterClassificationImpl::toUpper(rtl::OUString const&, int, int, com::sun::star::lang::Locale const&) :? (libi18npoollo.so+0x83855) (libutllo.so+0xc6f42) (libsvllo.so+0xc5823) const&) ??:? (libsclo.so+0x4978f3) const&, std::shared_ptr<oox::xls::RichString> const&) :? (libscfiltlo.so+0x46b354) const&, int) :? (libscfiltlo.so+0x46b44a) (libscfiltlo.so+0x4764a0) :? (libscfiltlo.so+0x4764e9) oox::core::ContextHandler2::endFastElement(int) ??:? (libooxlo.so+0x1a10eb) (libexpwraplo.so+0x2fbdf) (libexpwraplo.so+0x2fb21) char const*, unsigned char const*, unsigned char const*) fastparser.cxx:? (libexpwraplo.so+0x2c255) /build/libxml2-vTtzwD/libxml2-2.9.12+dfsg/builddir/main/../../parser.c:9736 (libxml2.so.2+0x5751a) (BuildId: baaa02c136f3351b1c499bbbbe94450b9b9c0d4e) /build/libxml2-vTtzwD/libxml2-2.9.12+dfsg/builddir/main/../../parser.c:9691 (libxml2.so.2+0x5751a) sax_fastparser::FastSaxParserImpl::parseStream(com::sun::star::xml::sax::InputSource const&) :? (libexpwraplo.so+0x2972d) sax_fastparser::FastSaxParser::parseStream(com::sun::star::xml::sax::InputSource const&) ??:? (libexpwraplo.so+0x30e88) oox::core::FastParser::parseStream(com::sun::star::xml::sax::InputSource const&, bool) ??:? (libooxlo.so+0x1a3220) oox::core::FastParser::parseStream(com::sun::star::uno::Reference<com::sun::star::io::XInputStream> const&, rtl::OUString const&) ??:? (libooxlo.so+0x1a3467) oox::core::XmlFilterBase::importFragment(rtl::Reference<oox::core::FragmentHandler> const&, oox::core::FastParser&) ??:? (libooxlo.so+0x1c46c1) oox::xls::WorkbookHelper::importOoxFragment(rtl::Reference<oox::core::FragmentHandler> const&, oox::core::FastParser&) :? (libscfiltlo.so+0x4be642) workbookfragment.cxx:? (libscfiltlo.so+0x4b618d) (libcomphelper.so+0x15e63b) (libuno_salhelpergcc3.so.3+0x5257) #25 threadFunc :? (libuno_salhelpergcc3.so.3+0x550e) (libuno_sal.so.3+0x67e25) Previous write of size 4 at 0x7b1c00035510 by thread T18 (mutexes: write M1): i18npool::Transliteration_casemapping::setMappingType(MappingType, com::sun::star::lang::Locale const&) :? (libi18npoollo.so+0xe5685) i18npool::cclass_Unicode::toUpper(rtl::OUString const&, int, int, com::sun::star::lang::Locale const&) :? (libi18npoollo.so+0x792fa) i18npool::CharacterClassificationImpl::toUpper(rtl::OUString const&, int, int, com::sun::star::lang::Locale const&) :? (libi18npoollo.so+0x83855) (libutllo.so+0xc6f42) (libsvllo.so+0xc5823) const&) ??:? (libsclo.so+0x4978f3) const&, std::shared_ptr<oox::xls::RichString> const&) :? (libscfiltlo.so+0x46b354) const&, int) :? (libscfiltlo.so+0x46b44a) (libscfiltlo.so+0x4764a0) :? (libscfiltlo.so+0x4764e9) oox::core::ContextHandler2::endFastElement(int) ??:? (libooxlo.so+0x1a10eb) (libexpwraplo.so+0x2fbdf) (libexpwraplo.so+0x2fb21) char const*, unsigned char const*, unsigned char const*) fastparser.cxx:? (libexpwraplo.so+0x2c255) /build/libxml2-vTtzwD/libxml2-2.9.12+dfsg/builddir/main/../../parser.c:9736 (libxml2.so.2+0x5751a) (BuildId: baaa02c136f3351b1c499bbbbe94450b9b9c0d4e) /build/libxml2-vTtzwD/libxml2-2.9.12+dfsg/builddir/main/../../parser.c:9691 (libxml2.so.2+0x5751a) sax_fastparser::FastSaxParserImpl::parseStream(com::sun::star::xml::sax::InputSource const&) :? (libexpwraplo.so+0x2972d) sax_fastparser::FastSaxParser::parseStream(com::sun::star::xml::sax::InputSource const&) ??:? (libexpwraplo.so+0x30e88) oox::core::FastParser::parseStream(com::sun::star::xml::sax::InputSource const&, bool) ??:? (libooxlo.so+0x1a3220) oox::core::FastParser::parseStream(com::sun::star::uno::Reference<com::sun::star::io::XInputStream> const&, rtl::OUString const&) ??:? (libooxlo.so+0x1a3467) oox::core::XmlFilterBase::importFragment(rtl::Reference<oox::core::FragmentHandler> const&, oox::core::FastParser&) ??:? (libooxlo.so+0x1c46c1) oox::xls::WorkbookHelper::importOoxFragment(rtl::Reference<oox::core::FragmentHandler> const&, oox::core::FastParser&) :? (libscfiltlo.so+0x4be642) workbookfragment.cxx:? (libscfiltlo.so+0x4b618d) (libcomphelper.so+0x15e63b) (libuno_salhelpergcc3.so.3+0x5257) #25 threadFunc :? (libuno_salhelpergcc3.so.3+0x550e) (libuno_sal.so.3+0x67e25) Change-Id: Idf8d9c307c09bc1af8541178331af23d146da927 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130787 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--i18npool/inc/cclass_unicode.hxx5
-rw-r--r--i18npool/source/characterclassification/cclass_unicode.cxx1
-rw-r--r--i18npool/source/characterclassification/cclass_unicode_parser.cxx16
-rw-r--r--i18npool/source/transliteration/transliteration_body.cxx3
4 files changed, 12 insertions, 13 deletions
diff --git a/i18npool/inc/cclass_unicode.hxx b/i18npool/inc/cclass_unicode.hxx
index 4ae4f5fd362e..3cfa1475a063 100644
--- a/i18npool/inc/cclass_unicode.hxx
+++ b/i18npool/inc/cclass_unicode.hxx
@@ -134,7 +134,6 @@ private:
std::unique_ptr<ParserFlags[]> pCont;
sal_Int32 nStartTypes;
sal_Int32 nContTypes;
- ScanState eState;
sal_Unicode cGroupSep;
sal_Unicode cDecimalSep;
sal_Unicode cDecimalSepAlt;
@@ -143,10 +142,10 @@ private:
static sal_Int32 getParseTokensType(sal_uInt32 c, bool isFirst);
/// Access parser table flags.
- ParserFlags getFlags(sal_uInt32 c);
+ ParserFlags getFlags(sal_uInt32 c, ScanState eState);
/// Access parser flags via International and special definitions.
- ParserFlags getFlagsExtended(sal_uInt32 c) const;
+ ParserFlags getFlagsExtended(sal_uInt32 c, ScanState eState) const;
/// Access parser table flags for user defined start characters.
ParserFlags getStartCharsFlags( sal_uInt32 c );
diff --git a/i18npool/source/characterclassification/cclass_unicode.cxx b/i18npool/source/characterclassification/cclass_unicode.cxx
index 2eb3fdf5f27d..45f222c60f6f 100644
--- a/i18npool/source/characterclassification/cclass_unicode.cxx
+++ b/i18npool/source/characterclassification/cclass_unicode.cxx
@@ -43,7 +43,6 @@ cclass_Unicode::cclass_Unicode( const uno::Reference < XComponentContext >& rxCo
m_xContext( rxContext ),
nStartTypes( 0 ),
nContTypes( 0 ),
- eState( ssGetChar ),
cGroupSep( ',' ),
cDecimalSep( '.' ),
cDecimalSepAlt( 0 )
diff --git a/i18npool/source/characterclassification/cclass_unicode_parser.cxx b/i18npool/source/characterclassification/cclass_unicode_parser.cxx
index 59f10339b5d3..313e42a0f2fe 100644
--- a/i18npool/source/characterclassification/cclass_unicode_parser.cxx
+++ b/i18npool/source/characterclassification/cclass_unicode_parser.cxx
@@ -557,13 +557,13 @@ void cclass_Unicode::destroyParserTable()
}
-ParserFlags cclass_Unicode::getFlags(sal_uInt32 const c)
+ParserFlags cclass_Unicode::getFlags(sal_uInt32 const c, const cclass_Unicode::ScanState eState)
{
ParserFlags nMask;
if ( c < nDefCnt )
nMask = pTable[ sal_uInt8(c) ];
else
- nMask = getFlagsExtended(c);
+ nMask = getFlagsExtended(c, eState);
switch ( eState )
{
case ssGetChar :
@@ -593,7 +593,7 @@ ParserFlags cclass_Unicode::getFlags(sal_uInt32 const c)
}
-ParserFlags cclass_Unicode::getFlagsExtended(sal_uInt32 const c) const
+ParserFlags cclass_Unicode::getFlagsExtended(sal_uInt32 const c, const cclass_Unicode::ScanState eState) const
{
if ( c == cGroupSep )
return ParserFlags::VALUE;
@@ -702,7 +702,7 @@ ParserFlags cclass_Unicode::getContCharsFlags( sal_Unicode c )
void cclass_Unicode::parseText( ParseResult& r, const OUString& rText, sal_Int32 nPos, sal_Int32 nTokenType )
{
assert(r.LeadingWhiteSpace == 0);
- eState = ssGetChar;
+ ScanState eState = ssGetChar;
//! All the variables below (plus ParseResult) have to be reset on ssRewindFromValue!
OUStringBuffer aSymbol;
@@ -723,7 +723,7 @@ void cclass_Unicode::parseText( ParseResult& r, const OUString& rText, sal_Int32
while ((current != 0) && (eState != ssStop))
{
++nCodePoints;
- ParserFlags nMask = getFlags(current);
+ ParserFlags nMask = getFlags(current, eState);
if ( nMask & ParserFlags::EXCLUDED )
eState = ssBounce;
if ( bMightBeWord )
@@ -827,7 +827,7 @@ void cclass_Unicode::parseText( ParseResult& r, const OUString& rText, sal_Int32
{
if (current == cGroupSep)
{
- if (getFlags(nextChar) & ParserFlags::VALUE_DIGIT)
+ if (getFlags(nextChar, eState) & ParserFlags::VALUE_DIGIT)
nParseTokensType |= KParseTokens::GROUP_SEPARATOR_IN_NUMBER;
else
{
@@ -850,7 +850,7 @@ void cclass_Unicode::parseText( ParseResult& r, const OUString& rText, sal_Int32
}
else if (current == 'E' || current == 'e')
{
- ParserFlags nNext = getFlags(nextChar);
+ ParserFlags nNext = getFlags(nextChar, eState);
if ( nNext & ParserFlags::VALUE_EXP )
; // keep it going
else if (bMightBeWord && ((nNext & ParserFlags::WORD) || !nextChar))
@@ -865,7 +865,7 @@ void cclass_Unicode::parseText( ParseResult& r, const OUString& rText, sal_Int32
{
if ( (cLast == 'E') || (cLast == 'e') )
{
- ParserFlags nNext = getFlags(nextChar);
+ ParserFlags nNext = getFlags(nextChar, eState);
if ( nNext & ParserFlags::VALUE_EXP_VALUE )
; // keep it going
else if (bMightBeWord && ((nNext & ParserFlags::WORD) || !nextChar))
diff --git a/i18npool/source/transliteration/transliteration_body.cxx b/i18npool/source/transliteration/transliteration_body.cxx
index e1fc11a8d70a..80072219780c 100644
--- a/i18npool/source/transliteration/transliteration_body.cxx
+++ b/i18npool/source/transliteration/transliteration_body.cxx
@@ -194,7 +194,8 @@ Transliteration_casemapping::Transliteration_casemapping()
void
Transliteration_casemapping::setMappingType( const MappingType rMappingType, const Locale& rLocale )
{
- nMappingType = rMappingType;
+ if (nMappingType != rMappingType)
+ nMappingType = rMappingType;
if (aLocale != rLocale)
aLocale = rLocale;
}