Opened 13 years ago
Closed 12 years ago
#3269 closed Bugs (fixed)
boost thread - mutex.lock() doesn't throw exception
Reported by: | anonymous | Owned by: | Anthony Williams |
---|---|---|---|
Milestone: | Boost 1.43.0 | Component: | thread |
Version: | Boost 1.43.0 | Severity: | Problem |
Keywords: | thread mutex lock | Cc: |
Description
lock() member function of mutex object doesn't throw any exception on error. There is no error handling capabilities because lock() doesn't return any value.
Change History (10)
comment:1 by , 13 years ago
Component: | None → thread |
---|---|
Owner: | set to |
follow-up: 3 comment:2 by , 13 years ago
comment:3 by , 13 years ago
Replying to steven_watanabe:
What errors do you expect from pthread_mutex_lock?
mutex.lock() call may fail - and it sometimes does (according, for example, to POSIX mutexes), so we need to know that something went wrong. One way to report an error is to throw system_error exception, like for example just::thread library does: http://www.stdthread.co.uk/doc/headers/mutex/mutex/lock.html
follow-up: 5 comment:4 by , 13 years ago
Well, it doesn't fail randomly. Most of the possible failures either cannot happen with boost::mutex or are a result of undefined behavior. However, EAGAIN and ENOMEM appear to be possible.
comment:5 by , 13 years ago
Replying to steven_watanabe:
Well, it doesn't fail randomly. Most of the possible failures either cannot happen with boost::mutex or are a result of undefined behavior. However, EAGAIN and ENOMEM appear to be possible.
On QNX pthread_mutex_lock may also return EDEADLK - if mutex was not set as recursive, or ETIMEDOUT if "A kernel timeout unblocked the call", and all this return values including EAGAIN are possible. At least this errors should be logged somewhere and execution of the thread should be cancelled.
comment:6 by , 13 years ago
Relocking a mutex that is already locked by the current thread is undefined behavior, so EDEADLK is irrelevant.
comment:7 by , 13 years ago
Milestone: | Boost 1.40.0 → Boost 1.41.0 |
---|---|
Version: | Boost 1.39.0 → Boost 1.40.0 |
comment:8 by , 13 years ago
Milestone: | Boost 1.41.0 → Boost 1.43.0 |
---|---|
Version: | Boost 1.40.0 → Boost 1.43.0 |
What errors do you expect from pthread_mutex_lock?