help needed: hsqldb shutdown race condition, how to fix without deadlock

Lionel Elie Mamane lionel at mamane.lu
Tue Jun 2 06:17:16 PDT 2015


On Tue, Jun 02, 2015 at 03:12:51PM +0200, Noel Grandin wrote:
> On 2015-06-02 03:07 PM, Lionel Elie Mamane wrote:
>> I found a race condition between

>> 1) connectivity::hsqldb::ODriverDelegator::flushConnections()
>>     (in file connectivity/source/drivers/hsqldb/HDriver.cxx around line 620)
>>     walking over m_aConnections

>> 2) connectivity::hsqldb::ODriverDelegator::disposing()
>>     (same file around line 565)
>>     calling

>>          m_aConnections.clear();
>>          TWeakPairVector().swap(m_aConnections);

>>     which invalidates the iterators used by flushConnection()

>> Plus also probably, race condition between flushConnections() calling
>> flush() and disposing() disposing the underlying connection (although
>> this is probably handled correctly by the exception catching...).

> I would suggest something like this in ODriverDelegator::flushConnections():

>     take_mutex();
>     std::vector<Connection> tmp = m_aConnections;
>     release_mutex();
>     for (Connection conn : tmp)
>         conn.flush();

> so that the mutex is not held during the problematic phase

That makes sense. Will try that. Thanks!

-- 
Lionel


More information about the LibreOffice mailing list