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

[FIXED] Possible crash if error handler if subscription was destroyed #659

Merged
merged 1 commit into from
Jun 2, 2023

Conversation

kozlovic
Copy link
Member

@kozlovic kozlovic commented Jun 1, 2023

Since error handler is invoked asynchronously, if the user had destroyed the subscription, it was possible that the error handler would be presented with a subscription that was already freed.

Signed-off-by: Ivan Kozlovic ivan@synadia.com

Since error handler is invoked asynchronously, if the user had
destroyed the subscription, it was possible that the error handler
would be presented with a subscription that was already freed.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
@kozlovic kozlovic requested a review from levb June 1, 2023 21:57
Copy link
Collaborator

@levb levb left a comment

Choose a reason for hiding this comment

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

LGTM! Let me try this with micro, see if it helps resolve the order of execution on shutdown issues there. It's a better fix than what I was trying to do just wrapping the invocation itself.

if (arg->status == NATS_OK)
{
// Call some subscription API to make sure that the pointer has not been freed.
arg->current = natsSubscription_IsValid(sub);
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

testCond(true);

test("Destroy subscription: ");
natsSubscription_Destroy(sub);
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@levb levb merged commit 585abc6 into main Jun 2, 2023
@levb levb deleted the fix_async_err_cbs branch June 2, 2023 13:12
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.

2 participants