[Bug 48886] New: LogiRegistryService (part of Logitech Gaming Software 8.x) hogs CPU, relying on blocking behaviour of 'wtsapi32.WTSWaitSystemEvent'

WineHQ Bugzilla wine-bugs at winehq.org
Sat Apr 4 13:50:19 CDT 2020


https://bugs.winehq.org/show_bug.cgi?id=48886

            Bug ID: 48886
           Summary: LogiRegistryService (part of Logitech Gaming Software
                    8.x) hogs CPU, relying on blocking behaviour of
                    'wtsapi32.WTSWaitSystemEvent'
           Product: Wine
           Version: 5.5
          Hardware: x86-64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: wtsapi32
          Assignee: wine-bugs at winehq.org
          Reporter: focht at gmx.net
      Distribution: ---

Hello folks,

as it says.

https://support.logi.com/hc/en-us/articles/360025298053

Download:

https://download01.logi.com/web/ftp/pub/techsupport/gaming/LGS_8.82.151_x64_Logitech.exe

Snapshot:

https://web.archive.org/web/20200404175412/https://download01.logi.com/web/ftp/pub/techsupport/gaming/LGS_8.82.151_x64_Logitech.exe

Installer log 'LGS8_setup.log':

--- snip ---
...
 installing "C:\Program Files\Logitech Gaming
Software\Drivers\APOService\LogiRegistryService.exe" -install returned 0
 starting "C:\Program Files\Logitech Gaming
Software\Drivers\APOService\LogiRegistryService.exe" -start returned 0
...
--- snip ---

Relevant part of trace log:

--- snip ---
$ WINEDEBUG=+seh,+relay,+msi,+wtsapi wine ./LGS_8.82.151_x64_Logitech.exe
>>log.txt 2>&1
...
011b:Call KERNEL32.CreateProcessW(00000000,0011eda0 L"\"C:\\Program
Files\\Logitech Gaming
Software\\Drivers\\APOService\\LogiRegistryService.exe\"",00000000,00000000,100000000,00000400,00889760,00000000,0022f5a0,0022f580)
ret=140006757 
...
011b:Ret  KERNEL32.CreateProcessW() retval=00000001 ret=140006757 
...
0125:Starting thread proc 0x7bccded0 (arg=0x11b760)
0125:Call wtsapi32.WTSWaitSystemEvent(00000000,00000028,00eefb00) ret=140004086
...
0125:Ret  wtsapi32.WTSWaitSystemEvent() retval=00000000 ret=140004086
0125:Call wtsapi32.WTSWaitSystemEvent(00000000,00000028,00eefb00) ret=140004086
0125:fixme:wtsapi:WTSWaitSystemEvent Stub 0000000000000000 0x00000028
0000000000EEFB00
0125:Ret  wtsapi32.WTSWaitSystemEvent() retval=00000000 ret=140004086
0125:Call wtsapi32.WTSWaitSystemEvent(00000000,00000028,00eefb00) ret=140004086
0125:fixme:wtsapi:WTSWaitSystemEvent Stub 0000000000000000 0x00000028
0000000000EEFB00
0125:Ret  wtsapi32.WTSWaitSystemEvent() retval=00000000 ret=140004086
0125:Call wtsapi32.WTSWaitSystemEvent(00000000,00000028,00eefb00) ret=140004086
0125:fixme:wtsapi:WTSWaitSystemEvent Stub 0000000000000000 0x00000028
0000000000EEFB00
0125:Ret  wtsapi32.WTSWaitSystemEvent() retval=00000000 ret=140004086 
...
011b:Call KERNEL32.ExitProcess(00000000) ret=7fc308ecdbdc
--- snip ---

--- snip ---
$ grep "Call wtsapi32.WTSWaitSystemEvent(" log.txt | wc -l
1934913
--- snip ---

Basically it uses 'WTSWaitSystemEvent' to monitor session changes.

0x28 = WTS_EVENT_CONNECT | WTS_EVENT_LOGON

* WTS_EVENT_CONNECT - A client connected to a WinStation.
* WTS_EVENT_LOGON - A user logged on to the system from either the Remote
Desktop Services console or from a client WinStation.

It only stops at one point because the installer schedules "reboot" which stops
the service. On WINEPREFIX restart, the autostart service hogs one core because
it endlessly calls this API in quick succession, spamming console as well.

Silencing the stub using FIXME-once is obviously not a proper solution. Faking
event data won't help either because the code runs in a thread that expects
"long time" blocking behaviour:

App code:

--- snip ---
...
0000000140004070 | lea r8,qword ptr ss:[rsp+60]             ; pEventFlags
0000000140004075 | mov edx,28                               ; EventMask
000000014000407A | xor ecx,ecx                              ; hServer
000000014000407C | mov dword ptr ss:[rsp+60],ebp            
0000000140004080 | call qword ptr ds:[<&WTSWaitSystemEvent>]; should block
0000000140004086 | mov ecx,dword ptr ss:[rsp+60]            ; pEventFlags
000000014000408A | mov dword ptr ss:[rsp+40],ecx            
000000014000408E | mov ebx,eax                              ; retval
0000000140004090 | lea rax,qword ptr ss:[rsp+60]            
0000000140004095 | mov qword ptr ss:[rsp+38],rax            
000000014000409A | mov dword ptr ss:[rsp+30],28             
00000001400040A2 | lea r9,qword ptr ds:[140024CA8]          
00000001400040A9 | mov r8d,C0                               
00000001400040AF | mov rdx,rsi                              
00000001400040B2 | mov ecx,5                                
00000001400040B7 | mov qword ptr ss:[rsp+28],rbp            
00000001400040BC | mov dword ptr ss:[rsp+20],ebx            
00000001400040C0 | call logiregistryservice.140004450       ; debug_message
00000001400040C5 | test ebx,ebx                             ; retval
00000001400040C7 | je logiregistryservice.1400040DA         
00000001400040C9 | mov rcx,qword ptr ds:[rdi+38]            
00000001400040CD | mov rcx,qword ptr ds:[rcx+218]           
00000001400040D4 | call qword ptr ds:[<&JMP.&SetEvent>]     ; signal oth thread
00000001400040DA | cmp byte ptr ds:[rdi+60],bpl             ; pEventFlags
00000001400040DE | jne logiregistryservice.140004070        ; loop again
00000001400040E0 | mov rcx,qword ptr ds:[rdi+58]            
00000001400040E4 | call qword ptr ds:[<&JMP.&SetEvent>]     
00000001400040EA | lea r9,qword ptr ds:[140024C70]          
...
--- snip --

Wine source:

https://source.winehq.org/git/wine.git/blob/7096ab45444d7b7cbb926b5a51af0cbc46960ed3:/dlls/wtsapi32/wtsapi32.c#l567

--- snip ---
 567 /************************************************************
 568  *                WTSWaitSystemEvent (WTSAPI32.@)
 569  */
 570 BOOL WINAPI WTSWaitSystemEvent(HANDLE hServer, DWORD Mask, DWORD* Flags)
 571 {
 572     /* FIXME: Forward request to winsta.dll::WinStationWaitSystemEvent */
 573     FIXME("Stub %p 0x%08x %p\n", hServer, Mask, Flags);
 574     return FALSE;
 575 }
--- snip ---

Microsoft docs:

https://docs.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtswaitsystemevent

$ sha1sum LGS_8.82.151_x64_Logitech.exe 
f21ae9214f8608ac192cd474c5f15734a75ca115  LGS_8.82.151_x64_Logitech.exe

$ du -sh LGS_8.82.151_x64_Logitech.exe 
117M    LGS_8.82.151_x64_Logitech.exe

$ wine --version
wine-5.5-242-g7096ab4544

Regards

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.


More information about the wine-bugs mailing list