-
Notifications
You must be signed in to change notification settings - Fork 598
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
Delivery handlers can be invoked with deallocated or modified memory contents #802
Comments
I don't understand what the problem really is and what options do we have. @stebet do you? |
I'll take a look, this shouldn't happen, as we're not supposed to dispose the pooled memory until the work has been completed. |
Alternatively, we can yield a copy to the delivery handler. We would lose some of the efficiency gains but safety is a very important factor for the users of this client. In fact, it remains to be seen how many would be tripped by the new copy-or-use requirements in 6.0. |
My thoughts exactly. We still shouldn't lose that much efficiency since that can be pooled as well. The overhead is just memory copies taking place, but allocations shouldn't be affected. I can make that change and submit it. |
Before making more changes, could we try to figure out why the existing code has a problem since @stebet you said you didn't think it was possible. |
@bording See my PR with the possible fix. It's due to the deliveries being put on separate worker pools, so after enqueuing the work. See line 58 in It adds memory copies and churn a bit, but should not increase allocations since they are also utilizing pooled memory. |
Eventually, we should just always do this in an async fashion, make message consumption async by default, and deprecate anything else (it's still possible to have Eventing and non-async on top of that). Then this can be done more reliably and we can simply avoid having any special-made worker/pooling constructs. I can take a look at that soonish. |
@stebet hey, we can do that as soon as 7.0 :) |
Fixed by #804. Thanks everyone! |
In #732 was introduced pooled message body ( 8bf9308 )
But the command is not invoked immediatly, just shedulled. So when the event handler is invoked, the command object can already be disposed and its memory region zeroed out/overwritten.
Test (@michaelklishin I made it single threaded) https://github.com/Anarh2404/rabbitmq-dotnet-client/blob/unexpected-frame-repro/projects/Unit/TestFloodPublishing.cs#L89
The text was updated successfully, but these errors were encountered: