Mir client library connection code is not threadsafe
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mir |
Fix Released
|
High
|
Alan Griffiths |
Bug Description
The mir client library code is supposed to be "thread safe within a single connection" (according to https:/
The problem is that we're using a global variable 'error_connection' for client connections that have errored. In mir_client_
MirConnection error_connection;
This then gets used in places like mir_connect (lines 51-74, but with some lines omitted below for clarity):
MirWaitHandle* mir_connect(char const* socket_file, char const* name, mir_connected_
{
try
{
// do some stuff..
return connection-
}
catch (std::exception const& x)
{
return 0;
}
}
The problem is the set_error_message, the implementation of which is simply:
void MirConnection:
{
error_message = error;
}
When trying to connect to the mir server from multiple threads, sometimes more than one thread will try and set the error message at the same time. This causes synchronisation issues, which often causes a double free inside std::string.
It's not enough to make this function thread safe however, we simply cannot use a single global variable to store errored connections.
Related branches
- Kevin DuBois (community): Approve
- PS Jenkins bot (community): Approve (continuous-integration)
- Alexandros Frantzis (community): Approve
-
Diff: 89 lines (+42/-9)1 file modifiedsrc/client/mir_client_library.cpp (+42/-9)
Changed in mir: | |
importance: | Undecided → High |
assignee: | nobody → Alan Griffiths (alan-griffiths) |
Changed in mir: | |
milestone: | none → 0.0.4 |
Changed in mir: | |
status: | Fix Committed → Fix Released |
Fix committed into lp:mir at revision None, scheduled for release in mir, milestone 0.0.4