summaryrefslogtreecommitdiff
path: root/include/o3tl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-08-04 15:58:34 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-08-04 18:15:00 +0200
commit2f343f09b4adaed1fe7286dfc8ba73bdb13eeabf (patch)
tree665a28cd6c77a89e384cd2d700360f84a80c1a60 /include/o3tl
parentee04805e513b0f804408697fc4b93e3c025d2329 (diff)
tsan:datarace in o3tl::ThreadSafeRefCountingPolicy
Because we a non-atomic read of the reference count. Which we shouldn't be doing anyway, or the ref-counting is broken. WARNING: ThreadSanitizer: data race (pid=121172) Read of size 4 at 0x7b100027ba38 by thread T5: /media/disk2/libo-san/include/o3tl/cow_wrapper.hxx:54:17 (libvcllo.so+0x7ee40d) o3tl::ThreadSafeRefCountingPolicy>::release() /media/disk2/libo-san/include/o3tl/cow_wrapper.hxx:208:29 (libvcllo.so+0x7ee40d) o3tl::ThreadSafeRefCountingPolicy>::~cow_wrapper() /media/disk2/libo-san/include/o3tl/cow_wrapper.hxx:260:13 (libvcllo.so+0x7ee40d) /media/disk2/libo-san/vcl/source/gdi/mapmod.cxx:97:19 (libvcllo.so+0x7ee40d) /media/disk2/libo-san/vcl/source/bitmap/bitmap.cxx:166:1 (libvcllo.so+0x92b175) /media/disk2/libo-san/vcl/source/bitmap/alpha.cxx:49:23 (libvcllo.so+0x946475) GraphicFilterImportFlags, vcl::ScopedBitmapAccess<BitmapWriteAccess, Bitmap, &(Bitmap::AcquireWriteAccess())>*, vcl::ScopedBitmapAccess<BitmapWriteAccess, AlphaMask, &(AlphaMask::AcquireAlphaWriteAccess())>*) /media/disk2/libo-san/vcl/source/filter/png/PngImageReader.cxx:383:1 (libvcllo.so+0xb67860) vcl::ScopedBitmapAccess<BitmapWriteAccess, Bitmap, &(Bitmap::AcquireWriteAccess())>*, vcl::ScopedBitmapAccess<BitmapWriteAccess, AlphaMask, &(AlphaMask::AcquireAlphaWriteAccess())>*) /media/disk2/libo-san/vcl/source/filter/png/PngImageReader.cxx:479:9 (libvcllo.so+0xb69139) namespace)::GraphicImportContext&) /media/disk2/libo-san/vcl/source/filter/graphicfilter.cxx:586:14 (libvcllo.so+0xac3a2f) /media/disk2/libo-san/vcl/source/filter/graphicfilter.cxx:574:5 (libvcllo.so+0xac3a2f) /media/disk2/libo-san/comphelper/source/misc/threadpool.cxx:314:9 (libcomphelper.so+0x1480ff) /media/disk2/libo-san/comphelper/source/misc/threadpool.cxx:83:24 (libcomphelper.so+0x1480ff) /media/disk2/libo-san/salhelper/source/thread.cxx:40:9 (libuno_salhelpergcc3.so.3+0x5350) /media/disk2/libo-san/salhelper/source/thread.cxx (libuno_salhelpergcc3.so.3+0x53b9) (libuno_salhelpergcc3.so.3+0x565e) /media/disk2/libo-san/sal/osl/unx/thread.cxx:264:9 (libuno_sal.so.3+0x68325) Previous atomic write of size 4 at 0x7b100027ba38 by main thread (mutexes: write M7453640868405680): /media/disk2/libo-san/include/o3tl/cow_wrapper.hxx:57:24 (libvcllo.so+0x7eebc9) o3tl::ThreadSafeRefCountingPolicy>::release() /media/disk2/libo-san/include/o3tl/cow_wrapper.hxx:208:29 (libvcllo.so+0x7eebc9) o3tl::ThreadSafeRefCountingPolicy>::operator=(o3tl::cow_wrapper<MapMode::ImplMapMode, o3tl::ThreadSafeRefCountingPolicy> const&) /media/disk2/libo-san/include/o3tl/cow_wrapper.hxx:269:13 (libvcllo.so+0x7eebc9) /media/disk2/libo-san/vcl/source/gdi/mapmod.cxx:124:45 (libvcllo.so+0x7eebc9) Change-Id: I6334b748b91bf414168c05d90fc5bd6d7dfe3dda Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120005 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/o3tl')
-rw-r--r--include/o3tl/cow_wrapper.hxx5
1 files changed, 1 insertions, 4 deletions
diff --git a/include/o3tl/cow_wrapper.hxx b/include/o3tl/cow_wrapper.hxx
index 8cc3651030fd..c05d28699259 100644
--- a/include/o3tl/cow_wrapper.hxx
+++ b/include/o3tl/cow_wrapper.hxx
@@ -51,10 +51,7 @@ namespace o3tl
static void incrementCount( ref_count_t& rCount ) { osl_atomic_increment(&rCount); }
static bool decrementCount( ref_count_t& rCount )
{
- if( rCount == 1 ) // caller is already the only/last reference
- return false;
- else
- return osl_atomic_decrement(&rCount) != 0;
+ return osl_atomic_decrement(&rCount) != 0;
}
};