Skip to content

Conversation

@bratpiorka
Copy link
Contributor

This fix prevents from the crash when urTearDown is called multiple time

@bratpiorka bratpiorka requested a review from a team as a code owner July 21, 2023 07:17
@bratpiorka bratpiorka temporarily deployed to aws July 21, 2023 07:32 — with GitHub Actions Inactive
for (ur_platform_handle_t Platform : *PiPlatformsCache) {
delete Platform;

if (PiPlatformsCache) {
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks @bratpiorka

@callumfare : does this conflict with your PR in #10349 ? would it be safe to merge this and then to rebase yours on top of it?

Copy link
Contributor

Choose a reason for hiding this comment

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

This will conflict but it should be a simple fix, I can rebase my PR when this is merged

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this patch will be necessary after your changes @callumfare since urTeardown will be an empty function and the actual teardown code (what this patch is changing) will be protected with a reference count.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good point, the case of multiple teardowns won't be a problem any more.

One related scenario I've just thought of is when the adapter is fully released and the reference count is 0, but is then reinitialized with a call to urAdapterGet again. The teardown should leave the adapter in a state where it's safe to call the setup code again. I'm not sure if this PR will ensure that but maybe that's something to consider in a future change.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks @callumfare , @pbalcer . So, do we want to not merge this patch in favor of yours?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's my recommendation.

@callumfare We should definitely have wording to that effect in the docs for related functions, with a matching CTS scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so I'll close this PR, thanks for the clarification

@bratpiorka bratpiorka temporarily deployed to aws July 21, 2023 08:10 — with GitHub Actions Inactive
@bratpiorka bratpiorka closed this Jul 25, 2023
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.

4 participants