basegfx/Library_basegfx.mk | 1 basegfx/source/tools/unopolypolygon.cxx | 34 +++++++++++++------------------ include/basegfx/utils/unopolypolygon.hxx | 8 ++----- vcl/inc/svdata.hxx | 2 - 4 files changed, 20 insertions(+), 25 deletions(-)
New commits: commit a235c8ddb1284757c97d92163bb6dea81ae6650f Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Dec 27 09:23:41 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Dec 27 11:49:13 2021 +0100 tsan: fix data race WARNING: ThreadSanitizer: data race (pid=4190705) Read of size 1 at 0x7fddb936aa7a by main thread (mutexes: write M0): #0 Application::Execute() /media/disk2/libo-tsan/vcl/source/app/svapp.cxx:443 (libvcllo.so+0xa5c998) #1 desktop::Desktop::Main() /media/disk2/libo-tsan/desktop/source/app/app.cxx:1594 (libsofficeapp.so+0x2bcd8) #2 ImplSVMain() /media/disk2/libo-tsan/vcl/source/app/svmain.cxx:199 (libvcllo.so+0xa68e8d) #3 SVMain() /media/disk2/libo-tsan/vcl/source/app/svmain.cxx:231 (libvcllo.so+0xa6b69f) #4 soffice_main /media/disk2/libo-tsan/desktop/source/app/sofficemain.cxx:98 (libsofficeapp.so+0x737c5) #5 sal_main /media/disk2/libo-tsan/desktop/source/app/main.c:51 (soffice.bin+0x4e5020) #6 main /media/disk2/libo-tsan/desktop/source/app/main.c:49 (soffice.bin+0x4e5020) Previous write of size 1 at 0x7fddb936aa7a by thread T7: #0 Application::Quit() /media/disk2/libo-tsan/vcl/source/app/svapp.cxx:542 (libvcllo.so+0xa5ce33) #1 framework::Desktop::terminate() /media/disk2/libo-tsan/framework/source/services/desktop.cxx:306 (libfwklo.so+0x23c4f4) #2 non-virtual thunk to framework::Desktop::terminate() /media/disk2/libo-tsan/framework/source/services/desktop.cxx:? (libfwklo.so+0x23dd79) #3 gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, double*) /media/disk2/libo-tsan/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:77 (libgcc3_uno.so+0xd6fe) #4 cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy*, bridges::cpp_uno::shared::VtableSlot, _typelib_TypeDescriptionReference*, int, _typelib_MethodParameter*, void*, void**, _uno_Any**) /media/disk2/libo-tsan/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:233 (libgcc3_uno.so+0xca27) #5 unoInterfaceProxyDispatch /media/disk2/libo-tsan/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:413 (libgcc3_uno.so+0xbfbe) #6 binaryurp::IncomingRequest::execute_throw(binaryurp::BinaryAny*, std::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >*) const /media/disk2/libo-tsan/binaryurp/source/incomingrequest.cxx:235 (libbinaryurplo.so+0x1c3f1) #7 binaryurp::IncomingRequest::execute() const /media/disk2/libo-tsan/binaryurp/source/incomingrequest.cxx:78 (libbinaryurplo.so+0x1b6a7) #8 request /media/disk2/libo-tsan/binaryurp/source/reader.cxx:85 (libbinaryurplo.so+0x24ceb) #9 cppu_threadpool::JobQueue::enter(void const*, bool) /media/disk2/libo-tsan/cppu/source/threadpool/jobqueue.cxx:100 (libuno_cppu.so.3+0x8bf2) #10 cppu_threadpool::ORequestThread::run() /media/disk2/libo-tsan/cppu/source/threadpool/thread.cxx:164 (libuno_cppu.so.3+0xb582) #11 non-virtual thunk to cppu_threadpool::ORequestThread::run() :? (libuno_cppu.so.3+0xb729) #12 threadFunc /media/disk2/libo-tsan/include/osl/thread.hxx:189 (libuno_cppu.so.3+0xbefe) #13 osl_thread_start_Impl(void*) /media/disk2/libo-tsan/sal/osl/unx/thread.cxx:264 (libuno_sal.so.3+0x68e15) Change-Id: I2cedecfe83fef85fb79614b9a77ab9cfe47d049b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127546 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index 21d12597d4e2..21bf0718298d 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -155,7 +155,7 @@ struct ImplSVAppData SystemWindowFlags mnSysWinMode = SystemWindowFlags(0); // Mode, when SystemWindows should be created bool mbInAppMain = false; // is Application::Main() on stack bool mbInAppExecute = false; // is Application::Execute() on stack - bool mbAppQuit = false; // is Application::Quit() called + volatile bool mbAppQuit = false; // is Application::Quit() called, volatile because we read/write from different threads bool mbSettingsInit = false; // true: Settings are initialized DialogCancelMode meDialogCancel = DialogCancelMode::Off; // true: All Dialog::Execute() calls will be terminated immediately with return false bool mbRenderToBitmaps = false; // set via svp / headless plugin commit 6464be15193cd0b54b4c1b8236b99e7971311c83 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Dec 27 09:35:11 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Dec 27 11:49:05 2021 +0100 use comphelper::WeakComponentImplHelper in UnoPolyPolygon Change-Id: I82248cfbb0cbdb765fa2f97f53e8990a9e05a28b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127547 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/basegfx/Library_basegfx.mk b/basegfx/Library_basegfx.mk index 8359969ae80c..2f9830d0dcfd 100644 --- a/basegfx/Library_basegfx.mk +++ b/basegfx/Library_basegfx.mk @@ -16,6 +16,7 @@ $(eval $(call gb_Library_set_precompiled_header,basegfx,basegfx/inc/pch/precompi $(eval $(call gb_Library_use_sdk_api,basegfx)) $(eval $(call gb_Library_use_libraries,basegfx,\ + comphelper \ cppu \ cppuhelper \ sal \ diff --git a/basegfx/source/tools/unopolypolygon.cxx b/basegfx/source/tools/unopolypolygon.cxx index 0d1696783c9f..48b3372d5526 100644 --- a/basegfx/source/tools/unopolypolygon.cxx +++ b/basegfx/source/tools/unopolypolygon.cxx @@ -34,7 +34,6 @@ using namespace ::com::sun::star; namespace basegfx::unotools { UnoPolyPolygon::UnoPolyPolygon( const B2DPolyPolygon& rPolyPoly ) : - UnoPolyPolygonBase( m_aMutex ), maPolyPoly( rPolyPoly ), meFillRule( rendering::FillRule_EVEN_ODD ) { @@ -46,7 +45,7 @@ namespace basegfx::unotools const geometry::RealPoint2D& position, const uno::Reference< rendering::XPolyPolygon2D >& polyPolygon ) { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); modifying(); // TODO(F1): Correctly fulfill the UNO API @@ -124,14 +123,14 @@ namespace basegfx::unotools sal_Int32 SAL_CALL UnoPolyPolygon::getNumberOfPolygons() { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); return maPolyPoly.count(); } sal_Int32 SAL_CALL UnoPolyPolygon::getNumberOfPolygonPoints( sal_Int32 polygon ) { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); checkIndex( polygon ); return maPolyPoly.getB2DPolygon(polygon).count(); @@ -139,14 +138,14 @@ namespace basegfx::unotools rendering::FillRule SAL_CALL UnoPolyPolygon::getFillRule() { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); return meFillRule; } void SAL_CALL UnoPolyPolygon::setFillRule( rendering::FillRule fillRule ) { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); modifying(); meFillRule = fillRule; @@ -155,7 +154,7 @@ namespace basegfx::unotools sal_Bool SAL_CALL UnoPolyPolygon::isClosed( sal_Int32 index ) { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); checkIndex( index ); return maPolyPoly.getB2DPolygon(index).isClosed(); @@ -165,7 +164,7 @@ namespace basegfx::unotools sal_Int32 index, sal_Bool closedState ) { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); modifying(); if( index == -1 ) @@ -192,8 +191,6 @@ namespace basegfx::unotools sal_Int32 nPointIndex, sal_Int32 nNumberOfPoints ) { - osl::MutexGuard const guard( m_aMutex ); - return unotools::pointSequenceSequenceFromB2DPolyPolygon( getSubsetPolyPolygon( nPolygonIndex, nNumberOfPolygons, @@ -205,7 +202,7 @@ namespace basegfx::unotools const uno::Sequence< uno::Sequence< geometry::RealPoint2D > >& points, sal_Int32 nPolygonIndex ) { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); modifying(); const B2DPolyPolygon& rNewPolyPoly( @@ -227,7 +224,7 @@ namespace basegfx::unotools sal_Int32 nPolygonIndex, sal_Int32 nPointIndex ) { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); checkIndex( nPolygonIndex ); const B2DPolygon& rPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) ); @@ -243,7 +240,7 @@ namespace basegfx::unotools sal_Int32 nPolygonIndex, sal_Int32 nPointIndex ) { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); checkIndex( nPolygonIndex ); modifying(); @@ -263,7 +260,6 @@ namespace basegfx::unotools sal_Int32 nPointIndex, sal_Int32 nNumberOfPoints ) { - osl::MutexGuard const guard( m_aMutex ); return unotools::bezierSequenceSequenceFromB2DPolyPolygon( getSubsetPolyPolygon( nPolygonIndex, nNumberOfPolygons, @@ -275,7 +271,7 @@ namespace basegfx::unotools const uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > >& points, sal_Int32 nPolygonIndex ) { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); modifying(); const B2DPolyPolygon& rNewPolyPoly( unotools::polyPolygonFromBezier2DSequenceSequence( points ) ); @@ -295,7 +291,7 @@ namespace basegfx::unotools geometry::RealBezierSegment2D SAL_CALL UnoPolyPolygon::getBezierSegment( sal_Int32 nPolygonIndex, sal_Int32 nPointIndex ) { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); checkIndex( nPolygonIndex ); const B2DPolygon& rPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) ); @@ -320,7 +316,7 @@ namespace basegfx::unotools sal_Int32 nPolygonIndex, sal_Int32 nPointIndex ) { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); checkIndex( nPolygonIndex ); modifying(); @@ -347,7 +343,7 @@ namespace basegfx::unotools sal_Int32 nPointIndex, sal_Int32 nNumberOfPoints ) const { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); checkIndex( nPolygonIndex ); const sal_Int32 nPolyCount( maPolyPoly.count() ); @@ -441,7 +437,7 @@ namespace basegfx::unotools B2DPolyPolygon UnoPolyPolygon::getPolyPolygon() const { - osl::MutexGuard const guard( m_aMutex ); + std::unique_lock const guard( m_aMutex ); // detach result from us B2DPolyPolygon aRet( maPolyPoly ); diff --git a/include/basegfx/utils/unopolypolygon.hxx b/include/basegfx/utils/unopolypolygon.hxx index b320998ac1a2..42da5921c7df 100644 --- a/include/basegfx/utils/unopolypolygon.hxx +++ b/include/basegfx/utils/unopolypolygon.hxx @@ -19,8 +19,7 @@ #pragma once -#include <cppuhelper/basemutex.hxx> -#include <cppuhelper/compbase.hxx> +#include <comphelper/compbase.hxx> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/rendering/FillRule.hpp> @@ -31,14 +30,13 @@ namespace basegfx::unotools { - typedef cppu::WeakComponentImplHelper< + typedef comphelper::WeakComponentImplHelper< css::rendering::XLinePolyPolygon2D, css::rendering::XBezierPolyPolygon2D, css::lang::XServiceInfo > UnoPolyPolygonBase; class BASEGFX_DLLPUBLIC UnoPolyPolygon - : private cppu::BaseMutex - , public UnoPolyPolygonBase + : public UnoPolyPolygonBase { public: explicit UnoPolyPolygon( const B2DPolyPolygon& );