Possible unreleased lock?
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_
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.
description: | updated |
description: | updated |
@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.