1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 07:13:02 +04:00

core(ocl): fix deadlock in UMatDataAutoLock

UMatData locks are not mapped on real locks (they are mapped to some "pre-initialized" pool).

Concurrent execution of these statements may lead to deadlock:
- a.copyTo(b) from thread 1
- c.copyTo(d) from thread 2
where:
- 'a' and 'd' are mapped to single lock "A".
- 'b' and 'c' are mapped to single lock "B".

Workaround is to process locks with strict order.
This commit is contained in:
Alexander Alekhin
2018-01-16 17:33:06 +03:00
parent ab8cf31ae9
commit cec700525c
5 changed files with 78 additions and 15 deletions
+3 -2
View File
@@ -123,6 +123,8 @@
#include "opencv2/core/opencl/opencl_svm.hpp"
#endif
#include "umatrix.hpp"
namespace cv { namespace ocl {
#define IMPLEMENT_REFCOUNTABLE() \
@@ -5424,8 +5426,7 @@ public:
srcrawofs, new_srcofs, new_srcstep,
dstrawofs, new_dstofs, new_dststep);
UMatDataAutoLock src_autolock(src);
UMatDataAutoLock dst_autolock(dst);
UMatDataAutoLock src_autolock(src, dst);
if( !src->handle || (src->data && src->hostCopyObsolete() < src->deviceCopyObsolete()) )
{