summaryrefslogtreecommitdiff
path: root/basegfx
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-05-31 16:15:52 +0200
committerMichael Stahl <mstahl@redhat.com>2017-05-31 16:36:04 +0200
commitcf382b6c0ea509d90855f348097dc0075671055d (patch)
treeb0529e262d7a6603d3e67714ba5cf4e250a6e9ab /basegfx
parent963137415bcdf3e7a26ce5d258302f4e39e294db (diff)
basegfx: remove global IdentityMatrix thread safety hazard
ASAN reports this about JunitTest_chart2_unoapi ==27381==ERROR: AddressSanitizer: heap-use-after-free on address 0x6060005bd218 at pc 0x7ff229755271 bp 0x7fffb52c6c30 sp 0x7fffb52c6c28 READ of size 8 at 0x6060005bd218 thread T0 #0 0x7ff229755270 in o3tl::UnsafeRefCountingPolicy::decrementCount(unsigned long&) include/o3tl/cow_wrapper.hxx:41:68 #1 0x7ff2297551bf in o3tl::cow_wrapper<basegfx::Impl2DHomMatrix, o3tl::UnsafeRefCountingPolicy>::release() include/o3tl/cow_wrapper.hxx:203:29 #2 0x7ff2297515f0 in o3tl::cow_wrapper<basegfx::Impl2DHomMatrix, o3tl::UnsafeRefCountingPolicy>::~cow_wrapper() include/o3tl/cow_wrapper.hxx:248:13 #3 0x7ff242ef440f in __run_exit_handlers (/lib64/libc.so.6+0x3a40f) #4 0x7ff242ef4469 in __GI_exit (/lib64/libc.so.6+0x3a469) The reason appears to be the UnsafeRefCountingPolicy on the global IdentityMatrix, so every B2DHomMatrix that is created on any thread will manipulate the refcount of that global without synchronisation. Let's just remove the global and hope the extra allocations don't matter. Change-Id: I4962ab2e622286f29b912a57448f3f1a53eeb592
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/source/matrix/b2dhommatrix.cxx15
1 files changed, 4 insertions, 11 deletions
diff --git a/basegfx/source/matrix/b2dhommatrix.cxx b/basegfx/source/matrix/b2dhommatrix.cxx
index b852a013a20a..f9bc24e81ea4 100644
--- a/basegfx/source/matrix/b2dhommatrix.cxx
+++ b/basegfx/source/matrix/b2dhommatrix.cxx
@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <rtl/instance.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <hommatrixtemplate.hxx>
#include <basegfx/tuple/b2dtuple.hxx>
@@ -32,11 +31,8 @@ namespace basegfx
{
};
- namespace { struct IdentityMatrix : public rtl::Static< B2DHomMatrix::ImplType,
- IdentityMatrix > {}; }
-
- B2DHomMatrix::B2DHomMatrix() :
- mpImpl( IdentityMatrix::get() ) // use common identity matrix
+ B2DHomMatrix::B2DHomMatrix()
+ : mpImpl() // identity
{
}
@@ -55,7 +51,7 @@ namespace basegfx
}
B2DHomMatrix::B2DHomMatrix(double f_0x0, double f_0x1, double f_0x2, double f_1x0, double f_1x1, double f_1x2)
- : mpImpl( IdentityMatrix::get() ) // use common identity matrix, will be made unique with 1st set-call
+ : mpImpl() // identity
{
mpImpl->set(0, 0, f_0x0);
mpImpl->set(0, 1, f_0x1);
@@ -104,15 +100,12 @@ namespace basegfx
bool B2DHomMatrix::isIdentity() const
{
- if(mpImpl.same_object(IdentityMatrix::get()))
- return true;
-
return mpImpl->isIdentity();
}
void B2DHomMatrix::identity()
{
- mpImpl = IdentityMatrix::get();
+ *mpImpl = Impl2DHomMatrix();
}
bool B2DHomMatrix::isInvertible() const