locking issues reported by the ThreadSanitizer in generated code
Submitted by Fabrice Bellet
Link to original bug (#778075)
Description
This report is a followup of bug #778005
In folks, there's this code block (folks/debug.vala):
public static Debug dup ()
{
lock (Debug._instance)
{
Debug? _retval = Debug._instance;
Debug retval;
if (_retval == null)
{
/* use an intermediate variable to force a strong reference */
retval = new Debug ();
Debug._instance = retval;
}
else
{
retval = (!) _retval;
}
return retval;
}
}
The vala generated code warns about a locking problem here, see attachment in bug #778005 for the TSan output:
- a static GRecMutex is locked at the beginning of the code block
- the lock is reset within the class constructor (retval = new Debug())
- and is unlocked at the end of the code block, causing the warning of TSan (unlock of an unlocked mutex).
Version: 0.34.x
Edited by Rico Tzschichholz