| Bug #42454 | Check return value of pthread_mutex_lock | ||
|---|---|---|---|
| Submitted: | 29 Jan 15:06 | Modified: | 30 Jan 12:03 |
| Reporter: | Jørgen Austvik | ||
| Status: | Verified | ||
| Category: | Server: General | Severity: | S4 (Feature request) |
| Version: | 5.0-bzr, 5.1-bzr, 6.0-bzr | OS: | Any |
| Assigned to: | Target Version: | ||
| Triage: | Needs Triage: D5 (Feature request) | ||
[30 Jan 12:03]
Valeriy Kravchuk
Verified by code review.

Description: Lots of places in the MySQL source code, we call pthread_mutex_lock(3C) without checking the return value for an error condition. Examples: my_open.c: pthread_mutex_lock(&THR_LOCK_open); my_pthread.h: #define thread_safe_increment(V,L) \ (pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L))) #define thread_safe_decrement(V,L) \ (pthread_mutex_lock((L)), (V)--, pthread_mutex_unlock((L))) pthread_mutex_lock() can fail with at least five different errors, if one of these happens, the call returns and the code will continue to run (thinking it has the mutex) even though the mutex is not locked. How to repeat: Use the source, Luke. Suggested fix: Check return value of pthread_mutex_lock(3C) with friends.