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

Comments

Projects
None yet
2 participants
@kalman5

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

This comment has been minimized.

Show comment
Hide comment
@viboes

viboes Apr 13, 2017

Collaborator

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?

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

This comment has been minimized.

Show comment
Hide comment
@viboes

viboes Apr 13, 2017

Collaborator

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.

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

This comment has been minimized.

Show comment
Hide comment
@kalman5

kalman5 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.

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

This comment has been minimized.

Show comment
Hide comment
@viboes

viboes Apr 14, 2017

Collaborator

Ok, I see.

Collaborator

viboes commented Apr 14, 2017

Ok, I see.

@viboes

This comment has been minimized.

Show comment
Hide comment
@viboes

viboes Aug 23, 2017

Collaborator

Done in boost 1.65.

Collaborator

viboes commented Aug 23, 2017

Done in boost 1.65.

@viboes viboes closed this Aug 23, 2017

@viboes viboes added fixed bug labels Aug 23, 2017

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