[PATCH] user32: Make functions use display dc thread-safe
Some functions in sysparams.c invoke get_display_dc to get display dc and then use it without lock mechanism. it will cause condition race in multi-thread. PS: I dont't kown how to make a test than can stably run into this problem, but call GetSystemMetrics(SM_CXSCREEN) within a tight loop in different thread will get zero finally.
On 1/12/2018 8:39 AM, 吕果 wrote:
Some functions in sysparams.c invoke get_display_dc to get display dc and then use it without lock mechanism. it will cause condition race in multi-thread.
PS: I dont't kown how to make a test than can stably run into this problem, but call GetSystemMetrics(SM_CXSCREEN) within a tight loop in different thread will get zero finally.
Hi. If the issue is get_display_dc() alone, you can use single compare-exchange call to set static variable safely.
The problem is not in get_display_dc() but use the value returned(HDC) without lock. ------------------ Original ------------------ From: "Nikolay Sivov"<bunglehead(a)gmail.com>; Date: Fri, Jan 12, 2018 03:56 PM To: "吕果"<lvguo(a)deepin.com>; "wine-devel"<wine-devel(a)winehq.org>; Subject: Re: [PATCH] user32: Make functions use display dc thread-safe On 1/12/2018 8:39 AM, 吕果 wrote:
Some functions in sysparams.c invoke get_display_dc to get display dc and then use it without lock mechanism. it will cause condition race in multi-thread.
PS: I dont't kown how to make a test than can stably run into this problem, but call GetSystemMetrics(SM_CXSCREEN) within a tight loop in different thread will get zero finally.
Hi. If the issue is get_display_dc() alone, you can use single compare-exchange call to set static variable safely.
Nikolay Sivov <bunglehead(a)gmail.com> writes:
On 1/12/2018 8:39 AM, 吕果 wrote:
Some functions in sysparams.c invoke get_display_dc to get display dc and then use it without lock mechanism. it will cause condition race in multi-thread.
PS: I dont't kown how to make a test than can stably run into this problem, but call GetSystemMetrics(SM_CXSCREEN) within a tight loop in different thread will get zero finally.
Hi.
If the issue is get_display_dc() alone, you can use single compare-exchange call to set static variable safely.
I expect that the issue is that you can't use the same DC from different threads at the same time. -- Alexandre Julliard julliard(a)winehq.org
participants (4)
-
Alexandre Julliard -
Guo Lv -
Nikolay Sivov -
吕果