Possible unreleased lock?

Bug #768379 reported by rexpie@gmail.com
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pbzip2
New
Undecided
Unassigned

Bug Description

pbzip2 ver 1.1.3:
pbzip2.cpp:
In the producer(int hInfile, int blockSize, queue *fifo) function, there is a piece of code: (line 2482)

outBuff * queueElement = new(std::nothrow) outBuff(FileData, inSize, NumBlocks, 0);
// make sure memory was allocated properly
if (queueElement == NULL)
{
 close(hInfile);
 handle_error(EF_EXIT, -1, "pbzip2: *ERROR: Could not allocate memory (queueElement)! Aborting...\n");
 return -1;
}

However improbable, but when the allocation do fail, the fifo->mut mutex is not unlocked when the function returns with an error. This is an analysis finding when we are doing research on finding unmatched lock/unlock statements. We are very grateful for your source code which has been very helpful for our research. Thank you.

Tags: lock
description: updated
description: updated
Revision history for this message
Yavor Nikolov (yavor-nikolov) wrote :

@rexpie, thank you very much for your analysis and for the reported issue.

What currently happens on handle_error is that the application will exit: so probably it doesn't matter much that this lock is not explicitly released (all resources will be released on exit).

Anyway - it's a good practice to avoid unmatched unlocks so thanks again for noticing that.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.