Repository: opencv
Issue: Data race in cv::resize
Labels: category: 3rdparty

### System Information

OpenCV version: 4.8.0
Operating System / Platform: Ubuntu 22.04.2 LTS
Compiler & compiler version: clang version 16.0.6

### Detailed description

When thread sanitizer is enabled, it gives a data race warning when using `cv::resize`.

### Steps to reproduce

```cpp
#include <opencv2/imgproc.hpp>

int main() {
    auto vSrcMat = ::cv::Mat(2056, 2464, CV_16U, cv::Scalar(0));
    auto vDstMat = ::cv::Mat(1028, 1232, CV_16U, cv::Scalar(0));
    int vMethod = 0;
    ::cv::resize(vSrcMat, vDstMat, vDstMat.size(), 0.0, 0.0, vMethod);
}
```
When running the executable, the following output is printed:
```log
[ INFO:0@0.011] global registry_parallel.impl.hpp:96 ParallelBackendRegistry core(parallel): Enabled backends(2, sorted by priority): TBB(1000); OPENMP(990)
[ INFO:0@0.011] global parallel_for.tbb.hpp:54 ParallelForBackend Initializing TBB parallel backend: TBB_INTERFACE_VERSION=12100
[ INFO:0@0.011] global parallel.cpp:77 createParallelForAPI core(parallel): using backend: TBB (priority=1000)
==================
WARNING: ThreadSanitizer: data race (pid=492398)
  Write of size 8 at 0x7b2000000000 by thread T1:
    #0 operator delete[](void*) <null> (bda_test+0x458d5f) (BuildId: 33abfa3452c1ab7c)
    #1 tbb::detail::r1::destroy_process_mask() /source_path/oneTBB/src/tbb/misc_ex.cpp:93:5 (libtbb_debug.so.12+0x7f2b5) (BuildId: 1fa7c16322d98be5)

  Previous read of size 8 at 0x7b2000000000 by thread T17:
    #0 memcmp <null> (bda_test+0x3dd040) (BuildId: 33abfa3452c1ab7c)
    #1 tbb::detail::r1::affinity_helper::protect_affinity_mask(bool) /source_path/oneTBB/src/tbb/misc_ex.cpp:113:26 (libtbb_debug.so.12+0x7f47a) (BuildId: 1fa7c16322d98be5)

  Thread T1 (tid=492400, running) created by main thread at:
    #0 pthread_create <null> (bda_test+0x3d0d4b) (BuildId: 33abfa3452c1ab7c)
    #1 tbb::detail::r1::rml::internal::thread_monitor::launch(void* (*)(void*), void*, unsigned long) /source_path/oneTBB/src/tbb/rml_thread_monitor.h:208:15 (libtbb_debug.so.12+0x877a5) (BuildId: 1fa7c16322d98be5)
    #2 __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 (libc.so.6+0x29d8f) (BuildId: 69389d485a9793dbe873f0ea2c93e02efaa9aa3d)

  Thread T17 (tid=492416, finished) created by thread T6 at:
    #0 pthread_create <null> (bda_test+0x3d0d4b) (BuildId: 33abfa3452c1ab7c)
    #1 tbb::detail::r1::rml::internal::thread_monitor::launch(void* (*)(void*), void*, unsigned long) /source_path/oneTBB/src/tbb/rml_thread_monitor.h:208:15 (libtbb_debug.so.12+0x877a5) (BuildId: 1fa7c16322d98be5)

SUMMARY: ThreadSanitizer: data race (/source_path/bda/bda_test+0x458d5f) (BuildId: 33abfa3452c1ab7c) in operator delete[](void*)
==================
ThreadSanitizer: reported 1 warnings

```

### Issue submission checklist

- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [X] I updated to the latest OpenCV version and the issue is still there
- [X] There is reproducer code and related data files (videos, images, onnx, etc)