Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snippets] Fixed set for Windows #17859

Merged

Conversation

a-sidorova
Copy link
Contributor

@a-sidorova a-sidorova commented Jun 2, 2023

Details:

  • Fixed SIGSEGV for Win OS

@github-actions github-actions bot added the category: CPU OpenVINO CPU plugin label Jun 2, 2023
@a-sidorova a-sidorova marked this pull request as ready for review June 2, 2023 11:17
@a-sidorova a-sidorova requested a review from a team as a code owner June 2, 2023 11:17
@a-sidorova a-sidorova added this to the 2023.1 milestone Jun 2, 2023
@a-sidorova
Copy link
Contributor Author

/azp run openvino-onnxruntime-lin

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@a-sidorova
Copy link
Contributor Author

/azp run openvino-ngraph-onnx-lin

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -106,7 +106,8 @@ void LinearIR::LoopManager::get_io_loop_ports(LinearIR::constExprIt loop_begin_p
const auto& expr = *expr_it;
for (size_t i = 0; i < expr->get_input_count(); ++i) {
const auto in_port = expr->get_input_port(i);
const auto& parent_expr = in_port.get_connected_ports().begin()->get_expr();
const auto source_port = *in_port.get_connected_ports().begin();
const auto& parent_expr = source_port.get_expr();
Copy link
Contributor

@dmitry-gorokhov dmitry-gorokhov Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please describe in details why original code led to segfault on Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I'm faced with this problem several times on ngraph (get_output_target_inputs has the same behavior) 😄

Let's take a look at previous 109 line:
get_connected_ports() returns sets of ExpressionPort instances (the method creates new set and returns it).
Then we take iterator on first element using begin() (this element is definitely in the set).
And we call get_expr from this first element and takes reference of shared pointer. But the set of connected ports is destroyed since it's local variable and isn't saved in this code frame. Thus, reference of shared pointer refs to destroyed memory as I understand. And we get corrupted data:
image
But as I said, this element is definitely in the set:
image

Sure, there is another solution. Save just the copy of shared pointer, not reference:

Suggested change
const auto& parent_expr = source_port.get_expr();
const auto parent_expr = in_port.get_connected_ports().begin()->get_expr();

for every taste 🙂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the explanation. On my personal taste I would prefer one line solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you say 😁
Done

@a-sidorova a-sidorova force-pushed the fix/snippets/set_iterator branch from 4d9bebf to 7089efe Compare June 8, 2023 14:37
@dmitry-gorokhov dmitry-gorokhov merged commit 883a70c into openvinotoolkit:master Jun 13, 2023
alvoron pushed a commit to alvoron/openvino that referenced this pull request Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: CPU OpenVINO CPU plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants