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

basic_condition_variable::relocker::~relocker can throw an exception #121

Closed
kalman5 opened this issue Apr 12, 2017 · 5 comments
Closed

Comments

@kalman5
Copy link

kalman5 commented Apr 12, 2017

relocker DTOR is implemented as the following:

            ~relocker()
            {
                if(unlocked)
                {
                    lock.lock();
                }

            }

that lock.lock() can throw (see unique_lock::lock in lock_types.hpp) leading to std::terminate if compiled in c++11 mode

@viboes
Copy link
Collaborator

viboes commented Apr 13, 2017

I will try to do the lock outside a destructor and propagate the exception.

Please could you tell me when do you see the call to terminate?

@viboes
Copy link
Collaborator

viboes commented Apr 13, 2017

The problem I have are the exception warranties.
What will be the state when there is a failure when trying to lock?
The resource will be unusable.
What the user should do when receiving an exception?

There are other uses similar to the relocker elsewhere in the library.

@kalman5
Copy link
Author

kalman5 commented Apr 13, 2017

You need to mark those DTOR as noexcept(false); if they can throw.
Basically even while not being inside a stack unwinding that will make the software terminating.

@viboes
Copy link
Collaborator

viboes commented Apr 14, 2017

Ok, I see.

@viboes
Copy link
Collaborator

viboes commented Aug 23, 2017

Done in boost 1.65.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants