Thread unsafe access to internal linked list, breaks Origin games in Wine

Bug #1062534 reported by Alessandro Pignotti on 2012-10-05
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
xlibs
Unknown
Medium
libx11 (Ubuntu)
Medium
Unassigned

Bug Description

In file src/xlibi18n/lcConv.c the following linked list head is defined

static XlcConverterList conv_list = NULL;

Which is then modified by _XlcSetConverter and get_converter in a non thread-safe manner. Inside get_converter the list is reorderder to increase the efficiency of looking up the same element the next time, but this is especially dangerous since a seemingly read-only method is actually modifying the data.

Modifying the list in such thread unsafe manner does case the list to become garbled in some workloads and causes infinite loops when the get_converter is invoked. The solution I suggest is to add a mutex or spinlock around accesses to the linked list, I would it myself but I'm not sure about what is the usual mutex implementation for this project.

In file src/xlibi18n/lcConv.c the following linked list head is defined

static XlcConverterList conv_list = NULL;

Which is then modified by _XlcSetConverter and get_converter in a non thread-safe manner. Inside get_converter the list is reorderder to increase the efficiency of looking up the same element the next time, but this is especially dangerous since a seemingly read-only method is actually modifying the data.

Modifying the list in such thread unsafe manner does case the list to become garbled in some workloads and causes infinite loops when the get_converter is invoked. The solution I suggest is to add a mutex or spinlock around accesses to the linked list, I would it myself but I'm not sure about what is the usual mutex implementation for this project.

Changed in xlibs:
importance: Unknown → Medium
status: Unknown → Confirmed

Also the following definitions:

static XlcDatabaseList _db_list = (XlcDatabaseList)NULL;

in file src/xlibi18n/lcDB.c is affected by the similar issues.

It looks like the localization support inside libx11 is generally not thread safe.

It should be noted that this is causing a lockup on the Origin game client under Wine, making a good chunk of games unplayable.

This bug affects the Origin games downloader in Wine, rendering a great swath of games unplayable.

Changed in libx11 (Ubuntu):
status: New → Confirmed
summary: - Type unsafe access to internal linked list
+ Type unsafe access to internal linked list, breaks Origin games in Wine

I've realized that I've made a typo in the type. The problem is with _thread_ safety, not type safety of course.

summary: - Type unsafe access to internal linked list, breaks Origin games in Wine
+ Thread unsafe access to internal linked list, breaks Origin games in
+ Wine

I'm attaching two internal pacthes that we use to fix the issue. They should be consider hacks to make the problem more clear.

The attachment "0001-Improve-thread-safety-of-localization.patch" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Bryce Harrington (bryce) on 2013-04-08
Changed in libx11 (Ubuntu):
assignee: nobody → Canonical X.org (canonical-x)
status: Confirmed → Triaged
importance: Undecided → High
Timo Aaltonen (tjaalton) wrote :

you should post patches on xorg-devel@ and discuss the bug on the upstream bugtracker, if you want this to get forward

Changed in libx11 (Ubuntu):
assignee: Canonical X.org (canonical-x) → nobody
importance: High → Medium

Created attachment 130584
A hack to improve the thread safety of the libX11 localization

Originally posted here: https://bugs.launchpad.net/ubuntu/+source/libx11/+bug/1062534 by Alessandro Pignotti

Created attachment 130585
A hack to remove an optimization that is thread unsafe

Originally posted here: https://bugs.launchpad.net/ubuntu/+source/libx11/+bug/1062534 by Alessandro Pignotti

Appended two patches from Alessandro Pignotti originally posted on the Ubuntu Bugzilla. They may or may not still be valid.

According to Alessandro's words, "They should be considered hacks to make the problem more clear."

Trying to attract some attention to this bug because I face it on a regular basis playing Lord of the Rings Online on Wine still after 5 years a patch has been proposed.

I'm a bit experienced in programming but only in Pascal and Python so I'm trying to find someone more experienced who could possibly fix it. If nobody responds, maybe I'll try to fix it myself…

-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xorg/lib/libx11/issues/24.

Changed in xlibs:
status: Confirmed → Unknown
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.