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

[HVX] Fix state_var issue #6894

Merged
merged 2 commits into from Aug 22, 2022
Merged

[HVX] Fix state_var issue #6894

merged 2 commits into from Aug 22, 2022

Conversation

rootjalex
Copy link
Member

The issue in #6893 is the result of an attempt to dereference a pointer to the module_state pointer. This PR simply adds a runtime method to dereference the pointer, in order to fix that issue. I'm not necessarily sure if this is the best approach, would love feedback from anyone who knows the HVX runtime better than I do.

@abadams
Copy link
Member

abadams commented Jul 28, 2022

@pranavb-ca might be able to weigh in

@@ -755,6 +755,13 @@ WEAK uint64_t halide_hexagon_get_device_size(void *user_context, struct halide_b
return handle->size;
}

WEAK void *halide_hexagon_get_module_state(void **host) {
if (host == nullptr) {
return nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is nullptr a value that the caller can deal with intelligently? (i.e., is this an error condition?)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not quite sure. This check doesn't exist in the current implementation, so perhaps I should remove it. I wanted to avoid null pointer dereferencing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Always a good idea. Might be worth throwing an abort() or similar in the null path to see?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, just tried it out in 2df1b2c

@rootjalex rootjalex linked an issue Jul 29, 2022 that may be closed by this pull request
@pranavb-ca
Copy link
Contributor

pranavb-ca commented Jul 29, 2022

LGTM. @aankit-ca can help you test this if you need. (sorry, i am on vacation with limited access to my work machine).

@rootjalex
Copy link
Member Author

Thanks for taking a look @pranavb-ca - sorry for bothering you on your vacation!

@steven-johnson
Copy link
Contributor

So how confident are we in this change? Do we have a way to verify that the null-check code is actually being exercised?

@rootjalex
Copy link
Member Author

I don't think we have a way to verify that it is, however this change is actually safer - the current version in main will just load without the nullptr check.

@rootjalex
Copy link
Member Author

@aankit-ca Any chance you could look at this? #6884 is stalled until this PR goes through

@steven-johnson
Copy link
Contributor

Monday review ping to @aankit-ca

@rootjalex
Copy link
Member Author

bump

@steven-johnson
Copy link
Contributor

If @aankit-ca isn't available for this review, we should either find someone else or just land it as-is.

@rootjalex rootjalex merged commit fd3bec3 into main Aug 22, 2022
@rootjalex rootjalex deleted the rootjalex/fix-hvx-state-var branch August 22, 2022 16:08
ardier pushed a commit to ardier/Halide-mutation that referenced this pull request Mar 3, 2024
* fix HVX state_var issue

* abort if host is nullptr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[HVX] InjectHexagonRpc breaks CSE
4 participants