help needed: hsqldb shutdown race condition, how to fix without deadlock
Noel Grandin
noelgrandin at gmail.com
Tue Jun 2 06:12:51 PDT 2015
On 2015-06-02 03:07 PM, Lionel Elie Mamane wrote:
> Hi,
>
> 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
More information about the LibreOffice
mailing list