openvino: [Bug] Infinite recursion if find_package(OpenVINODeveloperPackage) is called twice
System information (version)
- OpenVINO => 2022.3.0 and master
- Operating System / Platform => Ubuntu 22.04
- CMake => 3.22.1
- Problem classification: build scripts
Detailed description
The issue can be reproduced with simple CMakeLists.txt file:
cmake_minimum_required(VERSION 3.21)
project(openvino_cmake_bug_repro)
find_package(OpenVINODeveloperPackage REQUIRED)
find_package(OpenVINODeveloperPackage REQUIRED) # intentional second call
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/fake.cpp" [=[
int main(int argc, const char* argv[]) {
return 0;
}
]=])
add_executable(fake "${CMAKE_CURRENT_BINARY_DIR}/fake.cpp")
The second call of find_package(OpenVINODeveloperPackage REQUIRED) leads to infinite loop in CMake and the process is aborted by OS. In real life the above scenario might happen if one project uses another project as submodule and integrates it into single build tree and both projects use OpenVINO.
After some investigation, I found that the issue happens due to message function overriding here. When the find_package(OpenVINODeveloperPackage REQUIRED) is called the second time, the function is overriden again, but _message call inside now calls the function itself, not the base implementation. It leads to infinite recursion, when OpenVINODeveloperPackageConfig.cmake tries to print OpenVINO version. Some thread about similar issues in CMake can be found here: https://cmake.org/pipermail/cmake/2011-March/043316.html
The above example worked with OpenVINO 2022.2.0 because there ENABLE_ERROR_HIGHLIGHT option was set to OFF be default so the message was not overridden. In 2022.3.0 and master ENABLE_ERROR_HIGHLIGHT is turn on by default, which enables overriding and reveals this bug.
Steps to reproduce
Compile OpenVINO either with explicit -DENABLE_ERROR_HIGHLIGHT=ON option or without specifying it on 2022.3.0 or master. Then run CMake command with -DOpenVINODeveloperPackage_DIR=<path to OpenVINO build dir> on the above CMakeLists.txt example.
Issue submission checklist
- I report the issue, it’s not a question
- I checked the problem with documentation, FAQ, open issues, Stack Overflow, etc and have not found solution
- There is reproducer code and related data files: images, videos, models, etc.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (12 by maintainers)
@vinograd47 we have submitted this issue for dev team to take a look, will provide more details soon.
@ilya-lavrenov FYI
Ref. 104178
We don’t want to discuss workarounds here, the ticket was created to fix the bug in a specific use-case.