Skip to content

Close() throws exception from the destructor of ProducerClient causing the users to terminate, without an opportunity to catch the exception #6958

@Deepa-Pathak

Description

@Deepa-Pathak

Describe the bug
In our project, we sometimes recreate the ProducerClient to come out of idle channels scenario, we call Reset() on the producer client. Sometimes, we get terminated with the error: "Could not close message sender". Needless to ask, we have many try and catches in place to handle exceptions, but this exception was not handled.

Upon looking closer into the implementation, we got to the conclusion that Close() throws from the destructor, which is marked as noexcept, hence we terminate no matter what.

Close may throw that is fine but calling Close() from the destructor and then letting the exception propagate from destructor as per C++ standards will cause std::terminate to be called.

Close() is being called from here:

Exception or Stack Trace
"Could not close message sender", it comes from deep inside amqp implementation here:

if (messagesender_close(m_messageSender.get()))

To Reproduce
We can create a minimal example where a destructor throws in C++17. Real scenarion is difficult to reproduce as the underlying channel needs to throw while closing, which we cannot mimic.

It only happens when close() throws, similar code can be checked to understand the issue where the destructor throws.

Expected behavior
The ~ProducerClient() should not throw.

Setup (please complete the following information):
We're using vcpkg installed version with C++17.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Assignees

No one assigned

    Labels

    Event Hubscustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions