http://bugs.winehq.org/show_bug.cgi?id=11420
Summary: service control manager API problem: name of named objects might differ (client vs. service process) Product: Wine Version: 0.9.54. Platform: PC OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: advapi32 AssignedTo: wine-bugs@winehq.org ReportedBy: focht@gmx.net
Created an attachment (id=10552) --> (http://bugs.winehq.org/attachment.cgi?id=10552) patch which fixes client vs. service SCM API when using named objects
Hello,
there seems to be a misconception in usage of names for named objects in service control manager API. Some people might have experienced such situation: wine hangs for several seconds on startup (when starting services). I usually disabled autostart type services (except for builtin ones) and the problems went away.
Lately while fixing Microsoft Visual Studio .NET installers (2002/2003/2005) this problem became more and more annoying because the installers and VS.NET depend on some services, namely "debug manager" (service has to be running).
Consider the following snippet with "service_get_event_handle" trace message added by me to highlight the problem:
0x9: client (net.exe) 0x11: service process (mdm.exe) 0x12: dispatcher thread
--- snip trace --- .. 0009:trace:advapi:OpenSCManagerW ((null),(null),0x000f003f) 0009:trace:advapi:sc_handle_alloc sc_handle type=0 -> 0x121450 0009:trace:advapi:OpenSCManagerW returning 0x121450 (access : 0x000f003f) 0009:trace:advapi:OpenServiceA 0x121450 "mdm" 983103 0009:trace:advapi:OpenServiceW 0x121450 L"mdm" 983103 0009:trace:advapi:sc_handle_alloc sc_handle type=1 -> 0x121488 0009:trace:advapi:OpenServiceW returning 0x121488 0009:trace:advapi:GetServiceDisplayNameA 0x121450 "mdm" 0x34ee48 0x34fe48 0009:trace:advapi:GetServiceDisplayNameW 0x121450 L"mdm" 0x1214b8 0x34ee08 The Machine Debug Manager service is starting. 0009:trace:advapi:StartServiceA (0x121488,0,(nil)) 0009:trace:advapi:StartServiceW 0x121488 0 (nil) 0009:trace:advapi:LockServiceDatabase 0x121450 0009:trace:advapi:LockServiceDatabase returning 0x3c 0009:trace:advapi:service_start_process service_get_event_handle(L"mdm"): 0x40 0011:trace:advapi:LookupPrivilegeValueW L"",L"SeDebugPrivilege",0x34fc80 0011:trace:advapi:LookupPrivilegeValueW L"" -> 00000000-00000014 0011:trace:advapi:AdjustTokenPrivileges 0011:trace:advapi:StartServiceCtrlDispatcherA 0x34fc9c 0011:trace:advapi:service_run_threads Starting 1 pipe listener threads. Services running as process 16 0012:trace:advapi:service_control_dispatcher 0x121ea8 L"Machine Debug Manager" 0012:trace:advapi:service_control_dispatcher service_get_event_handle(L"Machine Debug Manager"): 0x48 0009:trace:advapi:UnlockServiceDatabase 0x3c 0009:trace:advapi:StartServiceW returning 0 The Machine Debug Manager service failed to start. 0009:trace:advapi:CloseServiceHandle 0x121488 0009:trace:advapi:sc_handle_destroy_service destroying service 0x121488 0009:trace:advapi:CloseServiceHandle 0x121450 0009:trace:advapi:sc_handle_destroy_manager destroying SC Manager 0x121450 000d:trace:advapi:service_run_threads last user process exited, shutting down 0011:trace:advapi:service_run_threads last user process exited, shutting down --- snip trace ---
When a service is started, named objects are created to internally communicate data/events from the service process (dispatcher) to client side SCM API and vice versa. Unfortunately there exist service proccesses which pass service names to dispatcher table (StartServiceCtrlDispatcher) not matching the service name on the client side (registry "Services" key).
--- snip dlls/advapi32/service.c --- static DWORD WINAPI service_control_dispatcher(LPVOID arg) { service_data *service = arg; LPWSTR name; HANDLE pipe, event;
TRACE("%p %s\n", service, debugstr_w(service->name));
/* create a pipe to talk to the rest of the world with */ name = service_get_pipe_name(service->name); <--------- *problem*! pipe = CreateNamedPipeW(name, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE|PIPE_WAIT, 1, 256, 256, 10000, NULL );
if (pipe==INVALID_HANDLE_VALUE) ERR("failed to create pipe for %s, error = %d\n", debugstr_w(service->name), GetLastError());
HeapFree(GetProcessHeap(), 0, name);
/* let the process who started us know we've tried to create a pipe */ event = service_get_event_handle(service->name); <--------- *problem*! SetEvent(event); CloseHandle(event); .. --- snip dlls/advapi32/service.c ---
As result, different named objects are created and signaled so the client side can't communicate with the service side using named pipe and events. This leads to infamous timeout problem (30 sec) and service startup failing.
In case of Microsoft Debug Manager the service is called "mdm" (registry). The service process itself passes "Microsoft Debug Manager" as name to dispatch table (see first trace).
Problem: how can both sides communicate a "common" name for named objects? The service dispatcher part on the service side has only dispatch table data available which doesn't help much.
I thought about this problem and found a feasible solution ... well call it "hack" whatever. If the client side API passes the service name in one of the process startup parameter members before process creation, the service process' dispatcher routine is able to access this data and create the named objects used for communication. I (ab)used startupinfo "title" member because only wine itself make exclusive use of most service process startup parameters. If not considered safe, use reserved/undoc fields...
With that patch applied the services in question start fine and can be controlled using "net" commands. No more hangs ;-)
Regards
http://bugs.winehq.org/show_bug.cgi?id=11420
Erich Hoover ehoover@mines.edu changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |ehoover@mines.edu
--- Comment #1 from Erich Hoover ehoover@mines.edu 2008-02-27 20:19:22 --- I would bet that name shows up in "HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/mdm" under the value "DisplayName"...
Are there any trial/demo links for this?
http://bugs.winehq.org/show_bug.cgi?id=11420
--- Comment #2 from Anastasius Focht focht@gmx.net 2008-02-28 04:06:21 --- Hello,
--- quote --- I would bet that name shows up in "HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/mdm" under the value "DisplayName"... --- quote ---
Possible. But that knowledge won't help you anyway. Consider the following snippet:
--- snip example --- int main(..) { .. SERVICE_TABLE_ENTRY serviceTable[] = { { "my service", (LPSERVICE_MAIN_FUNCTION) ServiceMain}, { NULL, NULL} };
.. StartServiceCtrlDispatcher(serviceTable); .. }
int install_service( ..) { .. HANDLE scm = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE); if (scm) { HANDLE svc = CreateService( scm, "MyService", "My Service Display Name", ...); .. } .. } --- snip example ---
Now you have:
1. service name "MyService" -> HKLM\SYSTEM\CurrentControlSet\Services\MyService 2. service (friendly) display name "My Service Display Name", under registry key (1) -> "DisplayName"="My Service Display Name" 3. service name in service process (compile/runtime) "my service" -> SERVICE_TABLE_ENTRY -> StartServiceCtrlDispatcher -> dlls/advapi32/service.c:service_control_dispatcher
No duplicate (1) and (2) are allowed with SCM. For duplicates in (3) I'm not sure.
Console start:
net start MyService net start "My Service Display Name"
--- quote --- Are there any trial/demo links for this? --- quote ---
Don't know, I'm using retail versions of VS.NET products. But you can write a simple test case with the example snippet given to verify this.
Regards
http://bugs.winehq.org/show_bug.cgi?id=11420
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- URL| |http://www.microsoft.com/dow | |nloads/details.aspx?familyid | |=9B3A2CA6-3647-4070-9F41- | |A333C6B9181D&displaylang=en
--- Comment #3 from Anastasius Focht focht@gmx.net 2008-03-24 17:10:42 --- Hello,
could this bug get a wine target milestone too? I consider this bug important not to be left out/forgotten. Several apps which install specific services are affected (VS.NET 7.x/.NET Framework SDK/various apps which use C-Dilla protection, e.g. AutoCAD 2K).
I've already described the problem in detail and gave a possible fix (although quick'n'dirty for proof-of-concept purpose).
The problem can be reproduced with the local/remote DevStudio Debugging Service that is shipped with .NET Framework SDK (NOTE the difference: .NET SDK != .NET redistributable)
1. clean your ~/.wine 2. install .NET 1.1 redistributable which is required prerequisite to SDK (if you use 'sh winetricks dotnet11' make sure winetricks script is up-to-date) 3. install .NET 1.1 SDK with default install settings
You might have to kill the SDK installer at some point due to that bug and others (hang symptoms, wineserver -k) - but don't kill it too early because the msi table joins take a while. You can then simulate with 'wine net start mdm'
Regards
http://bugs.winehq.org/show_bug.cgi?id=11420
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |1.0.0
--- Comment #4 from Austin English austinenglish@gmail.com 2008-03-24 18:15:11 --- Setting for 1.0, since we've got a patch/Anastasius's comments to go on.
http://bugs.winehq.org/show_bug.cgi?id=11420
Dan Kegel dank@kegel.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |dank@kegel.com
--- Comment #5 from Dan Kegel dank@kegel.com 2008-03-25 15:40:37 --- Odd - Louis just updated the howto in the appdb http://appdb.winehq.org/objectManager.php?sClass=version&iId=3754 and removed the workaround for this bug from his recipe. Has it been fixed somehow already?
http://bugs.winehq.org/show_bug.cgi?id=11420
--- Comment #6 from Anastasius Focht focht@gmx.net 2008-03-25 15:58:52 --- Hello,
--- quote --- Odd - Louis just updated the howto in the appdb http://appdb.winehq.org/objectManager.php?sClass=version&iId=3754 and removed the workaround for this bug from his recipe. Has it been fixed somehow already? --- quote ---
Don't think so. I think you fell for the .NET Framework _Redistributable_ vs. .NET Framework _SDK_ trap ;-)
.NET Framework Redistributable: runtime libraries to run .NET apps .NET Framework SDK: target audience = developers (additional libraries, tools, ...)
The workaround is not required for the .NET 2.0 "redist" package (doesn't contain that service). It's needed for the developer package which is shipped with VS.NET installations (or can be downloaded as single package).
Regards
http://bugs.winehq.org/show_bug.cgi?id=11420
Louis Lenders xerox_xerox2000@yahoo.co.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |xerox_xerox2000@yahoo.co.uk
--- Comment #7 from Louis Lenders xerox_xerox2000@yahoo.co.uk 2008-03-25 16:05:12 ---
Odd - Louis just updated the howto in the appdb http://appdb.winehq.org/objectManager.php?sClass=version&iId=3754 and removed the workaround
yeah, more then a week ago and earlier i noticed an annoying slow down ( had to wait 10 secs or so) for a .net app to start. In current git, it just starts immediately, and so i thought remove unneeded patches. I just tested 4 .net apps ( Friendbot, fastmd5, Paint.net and Autowikibrowser), and they all start instantly (though Paint.net has severe gui issues, and Autowikibrowser seems to freeze at a certain moment) using the current howto
http://bugs.winehq.org/show_bug.cgi?id=11420
--- Comment #8 from Dan Kegel dank@kegel.com 2008-03-25 16:06:51 --- OK, thanks.
BTW I'm tracking key .net 1.1 / 2.0 / visual studio install blockers at http://wiki.winehq.org/DanKegel, the idea being that once we get them cleared out, more people will be able to productively test for wine bugs in .net support.
http://bugs.winehq.org/show_bug.cgi?id=11420
Louis Lenders xerox_xerox2000@yahoo.co.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1
--- Comment #9 from Louis Lenders xerox_xerox2000@yahoo.co.uk 2008-04-02 01:17:29 --- Cool, some .net 2.0 apps now start fine using current git (still need corefonts and l_int.nls, nut no need for patching wine anymore). (Tested Paint.NET and Friendbot that previously segdaulted) This bug is the last one that more advanced .net 2.0 apps run into, like 3dsmax 9.0.
http://bugs.winehq.org/show_bug.cgi?id=11420
--- Comment #10 from Dan Kegel dank@kegel.com 2008-04-05 10:05:32 --- Can this bug be closed? Louis' last comment makes it sound like it's still open.
http://bugs.winehq.org/show_bug.cgi?id=11420
--- Comment #11 from Anastasius Focht focht@gmx.net 2008-04-05 11:07:29 --- Hello,
--- quote ---- Can this bug be closed? Louis' last comment makes it sound like it's still open. --- quote ----
Well, he talked about the service startup issue in 3dsmax/autocad products (http://bugs.winehq.org/show_bug.cgi?id=10787 and http://bugs.winehq.org/show_bug.cgi?id=8466). Bug 10787 was closed because the remaining issue was covered by Bug 8466 (left open for this purpose). Bug 8466 and this one cover probably the same issue.
Although there were various changes by Mikołaj Zalewski to introduce new services architecture, this specific issue has not been fixed yet (as of wine-0.9.59) My impression was that this would be fixed in near future so I refrained from posting updated patches.
Regards
http://bugs.winehq.org/show_bug.cgi?id=11420
Rob Shearman rob@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |rob@codeweavers.com
--- Comment #12 from Rob Shearman rob@codeweavers.com 2008-04-05 11:36:07 --- This commit was the one that should have fixed this bug: http://source.winehq.org/git/wine.git/?a=commit;h=b8348b95a6accb18ae1df8d2c9...
I tested this with the MDM service in the .NET SDK. If it's not fixed for other services, then new +service,+relay logs would be appreciated.
http://bugs.winehq.org/show_bug.cgi?id=11420
--- Comment #13 from Anastasius Focht focht@gmx.net 2008-04-05 12:40:02 --- Created an attachment (id=11873) --> (http://bugs.winehq.org/attachment.cgi?id=11873) WINEDEBUG=+seh,+tid,+relay,+service wine net start mdm
Hello,
--- quote --- I tested this with the MDM service in the .NET SDK. If it's not fixed for other services, then new +service,+relay logs would be appreciated. --- quote ---
Hmm ... when the MDM service calls RegisterServiceCtrlHandlerExW( L"Machine Debug Manager", ...) it still fails for me. OpenServiceW( L"Machine Debug Manager", ...) from RegisterServiceCtrlHandlerExW( L"Machine Debug Manager") -> null service handle. The RegisterServiceCtrlHandlerExW() return value is a bit mixed up in trace output due to threading, but it's actually 0.
Ok, that was a misunderstanding then ... I should have raised my hand earlier :|
Attached is trace (wine-0.9.59, clean .wine, dotnet11 redist + sdk).
'wineserver -k' 'WINEDEBUG=+seh,+tid,+relay,+service wine net start mdm >mdm_service_trace.txt 2>&1'
Regards
http://bugs.winehq.org/show_bug.cgi?id=11420
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |amaramrahul@gmail.com
--- Comment #14 from Austin English austinenglish@gmail.com 2008-04-07 04:54:51 --- *** Bug 12390 has been marked as a duplicate of this bug. ***
http://bugs.winehq.org/show_bug.cgi?id=11420
Paul Vriens Paul.Vriens.Wine@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |Paul.Vriens.Wine@gmail.com
http://bugs.winehq.org/show_bug.cgi?id=11420
--- Comment #15 from Dan Kegel dank@kegel.com 2008-05-06 12:09:36 --- *** Bug 12999 has been marked as a duplicate of this bug. ***
http://bugs.winehq.org/show_bug.cgi?id=11420
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED
--- Comment #16 from Alexandre Julliard julliard@winehq.org 2008-05-09 06:30:01 --- This should be fixed by 33914a1bf426f0d0d0670263b5b9f6fb24a87251.
http://bugs.winehq.org/show_bug.cgi?id=11420
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #17 from Alexandre Julliard julliard@winehq.org 2008-05-09 12:54:52 --- Closing bugs fixed in 1.0-rc1.
http://bugs.winehq.org/show_bug.cgi?id=11420
--- Comment #18 from Louis Lenders xerox_xerox2000@yahoo.co.uk 2008-05-09 13:29:01 --- looks like 3dsmax9 installer still fails in the end, with current git (with the patch in). I'll retest now to be sure
http://bugs.winehq.org/show_bug.cgi?id=11420
--- Comment #19 from Dan Kegel dank@kegel.com 2008-05-09 13:50:15 --- Yes, it does, but it gets further. We should file a new bug and link to it from bug 12999...
http://bugs.winehq.org/show_bug.cgi?id=11420
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, Installer Fixed by SHA1| |33914a1bf426f0d0d0670263b5b | |9f6fb24a87251
--- Comment #20 from Anastasius Focht focht@gmx.net 2011-10-12 03:54:30 CDT --- Hello,
filling/correcting fields ...
Regards
https://bugs.winehq.org/show_bug.cgi?id=11420
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- URL|http://www.microsoft.com/do |https://web.archive.org/web |wnloads/details.aspx?family |/20071012093921/http://down |id=9B3A2CA6-3647-4070-9F41- |load.microsoft.com/download |A333C6B9181D&displaylang=en |/5/2/0/5202f918-306e-426d-9 | |637-d7ee26fbe507/setup.exe