Repository: opencv
Issue: DNN/OpenCL Crashes on some Macs
Labels: bug,platform: ios/osx,category: ocl,category: dnn


##### System information (version)

- OpenCV => 3.3.1
- Operating System / Platform => Mac OS 10.12.6


##### Detailed description

Using DNN framework with OpenCL crashes on some Macs but not others. I've included the crash log. 

##### Detailed description

OS Version:            Mac OS X 10.12.6 (16G29)
Report Version:        12
Anonymous UUID:        60CB8BA8-3FBF-43E5-12ED-0FE4183AFF6B


Time Awake Since Boot: 580000 seconds

System Integrity Protection: disabled

Crashed Thread:        0  Dispatch queue: opencl_runtime

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000048
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]

VM Regions Near 0x48:
--> 
    __TEXT                 00000001039d2000-00000001039d4000 [    8K] r-x/rwx SM=COW  /usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

Thread 0 Crashed:: Dispatch queue: opencl_runtime
0   com.nvidia.web.GeForceGLDriverWeb	0x000000011197174c 0x111400000 + 5707596
1   com.nvidia.web.GeForceGLDriverWeb	0x000000011196ed5c 0x111400000 + 5696860
2   com.nvidia.web.GeForceGLDriverWeb	0x0000000111972194 0x111400000 + 5710228
3   com.nvidia.web.GeForceGLDriverWeb	0x000000011173785d 0x111400000 + 3373149
4   com.nvidia.web.GeForceGLDriverWeb	0x0000000111736837 0x111400000 + 3369015
5   com.nvidia.web.GeForceGLDriverWeb	0x000000011172f8c0 0x111400000 + 3340480
6   com.nvidia.web.GeForceGLDriverWeb	0x000000011172fc24 0x111400000 + 3341348
7   com.nvidia.web.GeForceGLDriverWeb	0x0000000111791a82 0x111400000 + 3742338
8   com.nvidia.web.GeForceGLDriverWeb	0x000000011176dd7c 0x111400000 + 3595644
9   com.nvidia.web.GeForceGLDriverWeb	0x000000011176cf1c 0x111400000 + 3591964
10  com.nvidia.web.GeForceGLDriverWeb	0x000000011176d3c2 gldFinishQueue + 279
11  com.apple.opencl              	0x00007fffbb42a818 0x7fffbb424000 + 26648
12  com.apple.opencl              	0x00007fffbb446f4d 0x7fffbb424000 + 143181
13  libdispatch.dylib             	0x00007fffcc7ac8fc _dispatch_client_callout + 8
14  libdispatch.dylib             	0x00007fffcc7ad536 _dispatch_barrier_sync_f_invoke + 83
15  libdispatch.dylib             	0x00007fffcc7b760d _dispatch_barrier_sync_f_slow + 540
16  com.apple.opencl              	0x00007fffbb447015 clFinish + 90
17  libopencv_core.3.3.dylib      	0x000000010856b77d cv::ocl::OpenCLAllocator::deallocate_(cv::UMatData*) const + 1161
18  libopencv_core.3.3.dylib      	0x0000000108568bbf cv::ocl::OpenCLAllocator::deallocate(cv::UMatData*) const + 439
19  libopencv_core.3.3.dylib      	0x00000001085d0a29 cv::UMat::~UMat() + 55
20  libopencv_dnn.3.3.dylib       	0x0000000104c0d39c std::__1::__vector_base<cv::UMat, std::__1::allocator<cv::UMat> >::~__vector_base() + 40
21  libopencv_dnn.3.3.dylib       	0x0000000104c0d26b cv::dnn::ConvolutionLayerImpl::~ConvolutionLayerImpl() + 31
22  libopencv_dnn.3.3.dylib       	0x0000000104c0a74e cv::dnn::ConvolutionLayerImpl::~ConvolutionLayerImpl() + 14
23  libopencv_dnn.3.3.dylib       	0x0000000104c127d6 cv::detail::PtrOwnerImpl<cv::dnn::ConvolutionLayerImpl, cv::DefaultDeleter<cv::dnn::ConvolutionLayerImpl> >::deleteSelf() + 24
24  libopencv_dnn.3.3.dylib       	0x0000000104c0292e cv::Ptr<cv::dnn::experimental_dnn_v2::Layer>::~Ptr() + 38
25  libopencv_dnn.3.3.dylib       	0x0000000104bfaaee cv::dnn::experimental_dnn_v2::LayerData::~LayerData() + 96
26  libopencv_dnn.3.3.dylib       	0x0000000104bfa4b4 std::__1::__tree<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::__map_value_compare<int, std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::less<int>, true>, std::__1::allocator<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData> > >::destroy(std::__1::__tree_node<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, void*>*) + 50
27  libopencv_dnn.3.3.dylib       	0x0000000104bfa49f std::__1::__tree<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::__map_value_compare<int, std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::less<int>, true>, std::__1::allocator<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData> > >::destroy(std::__1::__tree_node<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, void*>*) + 29
28  libopencv_dnn.3.3.dylib       	0x0000000104bfa49f std::__1::__tree<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::__map_value_compare<int, std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::less<int>, true>, std::__1::allocator<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData> > >::destroy(std::__1::__tree_node<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, void*>*) + 29
29  libopencv_dnn.3.3.dylib       	0x0000000104bfa4ab std::__1::__tree<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::__map_value_compare<int, std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::less<int>, true>, std::__1::allocator<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData> > >::destroy(std::__1::__tree_node<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, void*>*) + 41
30  libopencv_dnn.3.3.dylib       	0x0000000104bfa49f std::__1::__tree<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::__map_value_compare<int, std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::less<int>, true>, std::__1::allocator<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData> > >::destroy(std::__1::__tree_node<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, void*>*) + 29
31  libopencv_dnn.3.3.dylib       	0x0000000104bfa49f std::__1::__tree<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::__map_value_compare<int, std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::less<int>, true>, std::__1::allocator<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData> > >::destroy(std::__1::__tree_node<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, void*>*) + 29
32  libopencv_dnn.3.3.dylib       	0x0000000104bfa4ab std::__1::__tree<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::__map_value_compare<int, std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, std::__1::less<int>, true>, std::__1::allocator<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData> > >::destroy(std::__1::__tree_node<std::__1::__value_type<int, cv::dnn::experimental_dnn_v2::LayerData>, void*>*) + 41
33  libopencv_dnn.3.3.dylib       	0x0000000104c033f7 cv::dnn::experimental_dnn_v2::Net::Impl::~Impl() + 133
34  libopencv_dnn.3.3.dylib       	0x0000000104c0335d cv::detail::PtrOwnerImpl<cv::dnn::experimental_dnn_v2::Net::Impl, cv::DefaultDeleter<cv::dnn::experimental_dnn_v2::Net::Impl> >::deleteSelf() + 27
35  libopencv_dnn.3.3.dylib       	0x0000000104c88f42 cv::Ptr<cv::dnn::experimental_dnn_v2::Net::Impl>::~Ptr() + 38
36  cv2.so                        	0x0000000103de2df4 pyopencv_dnn_Net_dealloc(_object*) + 18
37  org.python.python             	0x0000000103a0e251 insertdict_by_entry + 259
38  org.python.python             	0x0000000103a0cbd3 insertdict + 51
39  org.python.python             	0x0000000103a0c2b7 dict_set_item_by_hash_or_entry + 101
40  org.python.python             	0x0000000103a10e63 _PyModule_Clear + 350
41  org.python.python             	0x0000000103a6edf4 PyImport_Cleanup + 499
42  org.python.python             	0x0000000103a795f5 Py_Finalize + 291
43  org.python.python             	0x0000000103a8ae79 Py_Main + 3153
44  libdyld.dylib                 	0x00007fffcc7e2235 start + 1