From e613b17c0541280bac59b36d5eaec53e7a1aed5a Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 18 Jan 2022 08:15:12 +0000 Subject: [PATCH 1/2] build(winpack_dldt): repair build with MSVS 2019 (16.11.9) --- .../20220118-dldt-fix-msvs-compilation-21469.patch | 12 ++++++++++++ platforms/winpack_dldt/2021.4.2/patch.config.py | 1 + 2 files changed, 13 insertions(+) create mode 100644 platforms/winpack_dldt/2021.4.2/20220118-dldt-fix-msvs-compilation-21469.patch diff --git a/platforms/winpack_dldt/2021.4.2/20220118-dldt-fix-msvs-compilation-21469.patch b/platforms/winpack_dldt/2021.4.2/20220118-dldt-fix-msvs-compilation-21469.patch new file mode 100644 index 0000000000..411d5cbd5c --- /dev/null +++ b/platforms/winpack_dldt/2021.4.2/20220118-dldt-fix-msvs-compilation-21469.patch @@ -0,0 +1,12 @@ +diff --git a/inference-engine/src/plugin_api/caseless.hpp b/inference-engine/src/plugin_api/caseless.hpp +index d8ce739..0dd8886 100644 +--- a/inference-engine/src/plugin_api/caseless.hpp ++++ b/inference-engine/src/plugin_api/caseless.hpp +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/platforms/winpack_dldt/2021.4.2/patch.config.py b/platforms/winpack_dldt/2021.4.2/patch.config.py index 7f8715aae2..bd31af236f 100644 --- a/platforms/winpack_dldt/2021.4.2/patch.config.py +++ b/platforms/winpack_dldt/2021.4.2/patch.config.py @@ -2,3 +2,4 @@ applyPatch('20210630-dldt-disable-unused-targets.patch') applyPatch('20210630-dldt-pdb.patch') applyPatch('20210630-dldt-disable-multidevice-autoplugin.patch') applyPatch('20210630-dldt-vs-version.patch') +applyPatch('20220118-dldt-fix-msvs-compilation-21469.patch') From 76e34d6f2c5ffee7e583d4384ff37f5afb9efb93 Mon Sep 17 00:00:00 2001 From: Vadim Levin Date: Tue, 18 Jan 2022 09:44:45 +0300 Subject: [PATCH 2/2] fix: handle possible PyModule_AddObject failure Comment from Python documentation: Unlike other functions that steal references, `PyModule_AddObject()` only decrements the reference count of value on success. This means that its return value must be checked, and calling code must `Py_DECREF()` value manually on error. --- modules/python/src2/pycompat.hpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/python/src2/pycompat.hpp b/modules/python/src2/pycompat.hpp index 2650554b3f..5c1bc2354f 100644 --- a/modules/python/src2/pycompat.hpp +++ b/modules/python/src2/pycompat.hpp @@ -229,7 +229,12 @@ PyObject* pyopencv_from(const TYPE& src) ERROR_HANDLER; \ } \ CVPY_TYPE_INCREF(pyopencv_##NAME##_TypePtr); \ - PyModule_AddObject(m, #WNAME, (PyObject *)pyopencv_##NAME##_TypePtr); \ + if (PyModule_AddObject(m, #WNAME, (PyObject *)pyopencv_##NAME##_TypePtr) < 0) \ + { \ + printf("Failed to register a new type: " #WNAME ", base (" #BASE ")\n"); \ + Py_DECREF(pyopencv_##NAME##_TypePtr); \ + ERROR_HANDLER; \ + } \ } //================================================================================================== @@ -302,10 +307,15 @@ PyObject* pyopencv_from(const TYPE& src) pyopencv_##NAME##_TypePtr = PyType_FromSpecWithBases(&pyopencv_##NAME##_Spec, bases); \ if (!pyopencv_##NAME##_TypePtr) \ { \ - printf("Failed to init: " #WNAME ", base (" #BASE ")" "\n"); \ + printf("Failed to create type from spec: " #WNAME ", base (" #BASE ")\n"); \ + ERROR_HANDLER; \ + } \ + if (PyModule_AddObject(m, #WNAME, (PyObject *)pyopencv_##NAME##_TypePtr) < 0) \ + { \ + printf("Failed to register a new type: " #WNAME ", base (" #BASE ")\n"); \ + Py_DECREF(pyopencv_##NAME##_TypePtr); \ ERROR_HANDLER; \ } \ - PyModule_AddObject(m, #NAME, (PyObject *)pyopencv_##NAME##_TypePtr); \ } // Debug module load: