-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Description
Describe the Bug
A mutex leak in update_current() causes permanent deadlock when an exception is thrown while holding the lock. When compiled with CONSISTENCY_CHECKING defined, the function acquires a mutex but throws std::runtime_error without releasing it.
Location: src/prioque.cpp (lines 331-346)
void update_current(Queue * q, void *element)
{
// lock entire queue
pthread_mutex_lock(&(q->lock)); // Line 331: Lock acquired
#if defined(CONSISTENCY_CHECKING)
if(q->queue == 0 || q->current == 0) {
std::string msg("Null pointer in function update_current()\n");
fprintf(stderr, "%s", msg.c_str());
throw std::runtime_error(msg); // Line 337: BUG - exception with lock held!
}
else
#endif
{
memcpy(q->current->info, element, q->elementsize);
}
// release lock on queue
pthread_mutex_unlock(&(q->lock)); // Line 346: Never reached on exception
}Impact:
- Queue mutex
q->lockremains permanently locked when exception is thrown - All subsequent queue operations block permanently
- File carving operations completely stall → Denial of Service
Execution Flow:
Thread 1:
→ pthread_mutex_lock(&(q->lock)) // Lock acquired
→ Check: q->queue == 0 || q->current == 0 // Condition TRUE
→ throw std::runtime_error(msg) // Exception thrown
→ pthread_mutex_unlock() SKIPPED // BUG: lock never released
→ q->lock remains locked forever
Thread 2, 3, ...N:
→ pthread_mutex_lock(&(q->lock)) // BLOCKS permanently
→ Complete deadlock state
I would appreciate it if you could review and confirm this potential issue. Thank you for your time and for maintaining this project!
Metadata
Metadata
Assignees
Labels
No labels