vcl/inc/impgraph.hxx |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 832ab453990608b6ccee6eb64d76af4a1114f44b
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Jul 1 13:42:04 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Jul 1 18:29:44 2025 +0200

    tsan: workaround a data-race
    
    this is not a great solution. It makes tsan happy (for now), but 
fundamentally,
    the drawinglayer code should not be relying on the vcl code being 
threadsafe.
    
    WARNING: ThreadSanitizer: data race (pid=252297)
      Write of size 8 at 0x724c000195e0 by thread T30:
        #0 ImpGraphic::resetLastUsed() const 
/home/noel/libo-tsan/vcl/source/gdi/impgraph.cxx:1799 (libvcllo.so+0x999ee6)
        #1 ImpGraphic::ensureAvailable() const 
/home/noel/libo-tsan/vcl/source/gdi/impgraph.cxx:1384 (libvcllo.so+0x999ee6)
        #2 ImpGraphic::getBitmapEx(GraphicConversionParameters const&) const 
/home/noel/libo-tsan/vcl/source/gdi/impgraph.cxx:652 (libvcllo.so+0x999ee6)
        #3 Graphic::GetBitmapEx(GraphicConversionParameters const&) const 
/home/noel/libo-tsan/vcl/source/gdi/graph.cxx:333 (libvcllo.so+0x98935d)
        #4 
drawinglayer::processor3d::DefaultProcessor3D::impRenderBitmapTexturePrimitive3D(drawinglayer::primitive3d::BitmapTexturePrimitive3D
 const&) 
/home/noel/libo-tsan/drawinglayer/source/processor3d/defaultprocessor3d.cxx:236 
(libdrawinglayerlo.so+0x14dc4e)
        #5 
drawinglayer::processor3d::DefaultProcessor3D::processBasePrimitive3D(drawinglayer::primitive3d::BasePrimitive3D
 const&) 
/home/noel/libo-tsan/drawinglayer/source/processor3d/defaultprocessor3d.cxx:496 
(libdrawinglayerlo.so+0x14f18d)
        #6 
drawinglayer::processor3d::BaseProcessor3D::process(drawinglayer::primitive3d::Primitive3DContainer
 const&) 
/home/noel/libo-tsan/drawinglayer/source/processor3d/baseprocessor3d.cxx:57 
(libdrawinglayerlo.so+0x14b9c2)
        #7 
drawinglayer::processor3d::DefaultProcessor3D::processBasePrimitive3D(drawinglayer::primitive3d::BasePrimitive3D
 const&) 
/home/noel/libo-tsan/drawinglayer/source/processor3d/defaultprocessor3d.cxx:539 
(libdrawinglayerlo.so+0x14f175)
        #8 
drawinglayer::processor3d::BaseProcessor3D::process(drawinglayer::primitive3d::Primitive3DContainer
 const&) 
/home/noel/libo-tsan/drawinglayer/source/processor3d/baseprocessor3d.cxx:57 
(libdrawinglayerlo.so+0x14b9c2)
        #9 
drawinglayer::primitive2d::ScenePrimitive2D::create2DDecomposition(drawinglayer::geometry::ViewInformation2D
 const&) const::Executor::doWork() 
/home/noel/libo-tsan/drawinglayer/source/primitive2d/sceneprimitive2d.cxx:466 
(libdrawinglayerlo.so+0xd3756)
        #10 comphelper::ThreadPool::ThreadWorker::execute() 
/home/noel/libo-tsan/comphelper/source/misc/threadpool.cxx:321 
(libcomphelper.so+0x169524)
        #11 non-virtual thunk to salhelper::Thread::run() 
/home/noel/libo-tsan/salhelper/source/thread.cxx:39 
(libuno_salhelpergcc3.so.3+0x5397)
        #12 threadFunc /home/noel/libo-tsan/include/osl/thread.hxx:189 
(libuno_salhelpergcc3.so.3+0x567e)
        #13 osl_thread_start_Impl(void*) 
/home/noel/libo-tsan/sal/osl/unx/thread.cxx:237 (libuno_sal.so.3+0x6b419)
    Change-Id: I04547be761db22443a4515af08b747483f5a7c20
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187237
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 5bfb12ababba..02bab2218e5e 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -70,7 +70,8 @@ private:
     std::optional<GraphicID>     mxGraphicID;
     GraphicExternalLink          maGraphicExternalLink;
 
-    mutable std::chrono::high_resolution_clock::time_point maLastUsed = 
std::chrono::high_resolution_clock::now();
+    // atomic because it is touched in parallel from the drawinglayer parallel 
rendering stuff in ScenePrimitive2D::create2DDecomposition
+    mutable std::atomic<std::chrono::high_resolution_clock::time_point> 
maLastUsed = std::chrono::high_resolution_clock::now();
     bool mbPrepared = false;
 
 public:

Reply via email to