openvino: Segmentation fault when running `test_get_runtime_model` test

Context

One of our tests results in a segfault error when ran by itself. This is probably related to Model object destruction. This task regards finding the error and fixing it. This task allows for quick familiarization with the internals of OpenVINO Python API.

Reproduction

The issue is reproducible with the following command:

python3 -m pytest tests/test_runtime/test_compiled_model.py::test_get_runtime_model -sv

which needs to be ran from openvino/src/bindings/python.

Resources

Contact points

@jiwaszki @akuporos @p-wysocki

Ticket: 113294

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 25 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Hi, thanks for assigning me the issue. I found that the previous comment had a mistake and I’ve updated it.

I also wrote a piece of C++ code that can reproduce the issue, which makes it a bit easier to debug.

#include <iostream>
#include <memory>

#include "openvino/core/model.hpp"
#include "openvino/opsets/opset8.hpp"
#include "openvino/runtime/core.hpp"

std::shared_ptr<ov::Model> create_simple_model() {
    auto data = std::make_shared<ov::opset8::Parameter>(ov::element::f32, ov::Shape{3, 1, 2});
    auto mul_constant = ov::opset8::Constant::create(ov::element::f32, ov::Shape{1}, {1.5});
    auto mul = std::make_shared<ov::opset8::Multiply>(data, mul_constant);
    auto res = std::make_shared<ov::opset8::Result>(mul);
    return std::make_shared<ov::Model>(ov::ResultVector{res}, ov::ParameterVector{data});
}

int main(int argc, char* argv[]) {
    auto model = create_simple_model();
    auto core = std::make_shared<ov::Core>();
    auto compiled_model = std::make_shared<ov::CompiledModel>(core->compile_model(model, "CPU"));
    auto runtime_model = compiled_model->get_runtime_model();
    std::cout << compiled_model << ' ' << runtime_model << std::endl;
    core.reset();
    compiled_model.reset();  // FreeLibrary happens here
    runtime_model.reset();   // segmentation fault happens here
    std::cout << compiled_model << ' ' << runtime_model << std::endl;
}

Sure, no worries, just checking in. 😃 There’s no rush, take your time - I’m just periodically checking our board for activity in the tasks, sometimes they get abandoned.